#13947 closed bug (fixed)
GHC 8.2 gives misleading error message for out-of-scope infix type constructor
Reported by: | RyanGlScott | Owned by: | RyanGlScott |
---|---|---|---|
Priority: | normal | Milestone: | 8.2.2 |
Component: | Compiler | Version: | 8.2.1-rc2 |
Keywords: | ORF | Cc: | adamgundry |
Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
Type of failure: | Poor/confusing error message | Test Case: | |
Blocked By: | Blocking: | ||
Related Tickets: | Differential Rev(s): | Phab:D3718 | |
Wiki Page: |
Description
{-# 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.
Change History (8)
comment:1 Changed 20 months ago by
Cc: | adamgundry added |
---|
comment:2 Changed 20 months ago by
Keywords: | ORF added |
---|
comment:3 Changed 20 months ago by
Owner: | set to RyanGlScott |
---|
After skimming the commitdiff, I'm reasonably confident I know what is happening, and how fix it. I'll post a Phab Diff after I've validated.
Also, I just realized that there's another problem with the error message in GHC 8.2: it claims that a constructor :~:
is in scope, but that's untrue. I'll submit a separate ticket for this later.
comment:4 Changed 20 months ago by
Differential Rev(s): | → Phab:D3718 |
---|---|
Status: | new → patch |
comment:5 Changed 20 months ago by
I've opened #13948 for the A data constructor of that name is in scope
issue.
comment:7 Changed 20 months ago by
Milestone: | → 8.2.2 |
---|---|
Status: | patch → merge |
comment:8 Changed 18 months ago by
Resolution: | → fixed |
---|---|
Status: | merge → closed |
Merged to ghc-8.2
with 45588a00c06d5ee5a0fe24974f586340ab03d2de.
This started occurring in commit 2484d4dae65c81f218dcfe494b963b2630bb8fa6 (
Refactor renaming of operators/sections to fix DuplicateRecordFields bugs
).