GHC does not follow offside rule specified as in Haskell Standard
GHC parses the following code wrongly according to the Haskell Standard (both 98 and 2010):
foo =
do twice $ do
putStrLn "abc"
putStrLn "def"
GHC does:
foo =
do {twice $ do
{putStrLn "abc"
;putStrLn "def"}}
According to the Haskell Standard, the augmented input stream is:
foo =
<3>do {6}twice $ do
{6}putStrLn "abc"
<6>putStrLn "def"
When considering the second '{6}' token, the stack of layout contexts consists of the single entry '6'. Therefore, only the fifth layout rule applies, which prescribes an empty block (even though empty do blocks are illegal). Layout rule in Haskell Standard
Thus, GHC should parse the above example as follows (and indicate an error regarding the empty do block):
foo =
do {twice $ do {}
;putStrLn "abc"
;putStrLn "def"}
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Parser) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |