Skip to content

Incorrect parsing of declarations

GHC's parser seems to accept incorrect Haskell programs, which leads to very confusing error messages. Here is an example:

f x = T
 
g 1 = 10
g x

data T = T

When trying to compile this GHC reports:

test.hs:1:6: Not in scope: data constructor `T'

This happened in much larger module, where I had forgotten to complete one of the equations for a function, but ended up looking for what is wrong with the (completely unrelated) "data" declaration.

This might be related to Template Haskell because a smaller example---a file containing only the literal 1---results in complaints about some template Haskell type not being in the Num class.

I am compiling the module without any pragmas or flags, so I would not think that TH is enabled.

Trac metadata
Trac field Value
Version 6.12.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Parser)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information