Skip to content

Can't use explicit braces/semicolons (i.e. non-layout) at top level with ghci

The following file is rejected by ghc and ghci, but accepted by hugs.

{
x =
3;
}

The work-around is to include 'module Main where' before the opening brace in the first line.

The error reported is:

layoutbug.hs:1:0: parse error on input `{'

I discovered this bug whilst assisting a programmer who uses a screenreader and hence finds layout code quite unhelpful. Blind and partially sighted users in general may well hit this problem!

My reading of the haskell report suggests that the code above is valid haskell98 (looking at the grammar, one alternative for 'module' is 'body', and 'body' can be { topdecls } )

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