#5330: GHC does not follow offside rule specified as in Haskell Standard
---------------------------------+------------------------------------------
Reporter: seba | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (Parser)
Version: 7.0.3 | Keywords: layout, offside
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: GHC accepts invalid program
---------------------------------+------------------------------------------
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).
[http://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-17800010.3
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"}
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5330>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs