[GHC] #13947: GHC 8.2 gives misleading error message for out-of-scope infix type constructor
GHC
ghc-devs at haskell.org
Sun Jul 9 17:16:13 UTC 2017
#13947: GHC 8.2 gives misleading error message for out-of-scope infix type
constructor
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1-rc2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Poor/confusing
Unknown/Multiple | error message
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
{{{#!hs
{-# LANGUAGE TypeOperators #-}
module Bug where
f :: () -> Int :~: Int
f = undefined
}}}
GHC 8.0.2 gives a reasonable error message:
{{{
$ /opt/ghc/8.0.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:4:12: error: Not in scope: type constructor or class ‘:~:’
}}}
But GHC 8.2.1's error message is much more confusing:
{{{
$ /opt/ghc/8.2.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:4:6: error:
Precedence parsing error
cannot mix ‘(->)’ [infixr 0] and ‘:~:’ [infixl 0] in the same
infix expression
|
4 | f :: () -> Int :~: Int
| ^^^^^^^^^^^^^^^^^
Bug.hs:4:12: error:
Not in scope: type constructor or class ‘:~:’
A data constructor of that name is in scope; did you mean DataKinds?
|
4 | f :: () -> Int :~: Int
| ^^^^^^^^^^^
}}}
I was thrown akilter by the claim that `:~:` was `infixl 0`, since it was
displayed before the real cause of the error (that it's out-of-scope).
Adding `import Data.Type.Equality` fixes the error, but GHC really
shouldn't be making claims about the fixities of out-of-scope type
constructors in the first place.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13947>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list