GHC accepts import of private data constructor if it has the same name as the type
|Reported by:||Lemming||Owned by:|
|Type of failure:||GHC accepts invalid program||Test Case:||rename/should_fail/T9006|
|Related Tickets:||Differential Rev(s):|
$ cat A.hs B.hs module A (T) where data T = T module B where import A (T(T))
ghci-7.8.2 accepts module B, whereas ghci-7.6.3 and ghci-7.4.2 say:
B.hs:3:11: Module `A' does not export `T(T)'
For this bug to happen it is important, that the data constructor has the same name as the type. I.e. if you rename the data constructor to, say, Cons, then ghci-7.8.2 will emit the same error as earlier versions. The bug is not dramatic, since if you try to actually use the imported data constructor then ghc will say
B.hs:20:5: Not in scope: data constructor ‘T’
However this error message is very confusing, because it suggests that T is not in scope although you imported it correctly.
Change History (4)
comment:1 Changed 20 months ago by simonpj
- Resolution set to fixed
- Status changed from new to closed
- Test Case set to rename/should_fail/T9006