Skip to content

Able to add bogus HasCallStack constraint to instance methods with InstanceSigs

Summary

You can use incorrectly add HasCallStack constraints to signatures in instances.

Thanks to MangoIV for finding this issue.

Steps to reproduce

import Data.Kind (Type)
import GHC.Stack (HasCallStack, prettyCallStack, callStack)

class C (a :: Type) where
  cj :: a -> String

instance C () where
  cj :: HasCallStack => () -> String
  cj _ = prettyCallStack callStack

f :: String
f = cj () -- equal to ""

Expected behavior

This should err.

Environment

  • GHC version used: 9.2.4
Edited by Las Safin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information