[GHC] #11793: Confusing type error from constrained class method
GHC
ghc-devs at haskell.org
Tue Apr 5 18:01:27 UTC 2016
#11793: Confusing type error from constrained class method
-------------------------------------+-------------------------------------
Reporter: gridaphobe | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version: 8.0.1-rc2
Keywords: error-message | Operating System: Unknown/Multiple
Architecture: | Type of failure: Incorrect
Unknown/Multiple | warning at compile-time
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
{{{#!hs
import GHC.Stack
class Foo a where
foo :: HasCallStack => a -> String
instance Foo () where
foo () = prettyCallStack callStack
main = putStrLn (foo ())
}}}
{{{
~/S/ghc> ./inplace/bin/ghc-stage2 --make Foo.hs
[1 of 1] Compiling Main ( Foo.hs, Foo.o )
Foo.hs:4:3: error:
• Constraint ‘HasCallStack’ in the type of ‘foo’
constrains only the class type variables
Use ConstrainedClassMethods to allow it
• When checking the class method:
foo :: forall a. (Foo a, HasCallStack) => a -> String
In the class declaration for ‘Foo’
}}}
The error says that `HasCallStack` constrains the class type variable `a`,
which is incorrect. Is the error message supposed to be that
`HasCallStack` '''should''' constrain the class type variable and nothing
else?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11793>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list