GHC 8.2 gives misleading error message for out-of-scope infix type constructor
{-# 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.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |