Opened 9 years ago

Closed 9 years ago

#5243 closed bug (fixed)

ghc --make and ghci misses dependencies with explicit braces

Reported by: simonpj Owned by: simonmar
Priority: high Milestone: 7.2.1
Component: Compiler Version: 7.0.3
Keywords: Cc: crary@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: parser/should_compile/T5243
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Karl Crary tripped over this deeply strange case:

   module Bar where
   bar = True

   { import Bar; main = print bar }

Notice that Main.hs is missing its "module Main where" part, but has explicit braces and semicolons. The BNF in the language standard says that is fine.

If you compile them one at a time all is well:

ghc -c Bar.hs
ghc -c Main.hs 

But if you use --make it breaks:

simonpj@cam-04-unx:~/tmp$ ghc --make Main -ddump-parsed -ddump-rn
[1 of 1] Compiling Main             ( Main.hs, Main.o )

==================== Parser ====================
import Bar
main = print foo

Main.hs:1:29: Not in scope: `foo'

Bizarre, eh? This is ghc 7.0.3. It's as if --make somehow ignores the import of Bar, even though it is parsed just fine.


Change History (5)

comment:1 Changed 9 years ago by simonmar

Owner: set to simonmar
Type of failure: None/UnknownGHC rejects valid program

The bug appears to be in the parser: Parser.parseHeader does not handle the case where a module consists of explicit curly braces with no module header (see body2 in Parser.y).

comment:2 Changed 9 years ago by marlowsd@…

commit bf04ddcce48856a4185c05bd890635b9450762a4 Author: Simon Marlow <marlowsd@…> Date: Tue Jul 12 11:48:00 2011 +0100

Fix bug in parsing of module headers (see #5243)

comment:3 Changed 9 years ago by simonmar

Status: newmerge

comment:4 Changed 9 years ago by simonpj

Test Case: parser/should_compile/T5243

comment:5 Changed 9 years ago by igloo

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.