Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#1253 closed bug (fixed)

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

Reported by: guest Owned by:
Priority: normal Milestone: 6.8.1
Component: Compiler (Parser) Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Test Case: read045
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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 } )

Change History (6)

comment:1 Changed 8 years ago by igloo

  • Milestone set to 6.6.2

The report seems quite clear that we should accept this:

An abbreviated form of module, consisting only of the module body, is permitted. If this is used, the header is assumed to be `module Main(main) where'. If the first lexeme in the abbreviated module is not a {, then the layout rule applies for the top level of the module.

but we don't in either 6.6 branch or HEAD.

comment:2 Changed 8 years ago by simonmar

  • Milestone changed from 6.6.2 to 6.8

comment:3 Changed 8 years ago by simonmar

  • Component changed from Compiler to Compiler (Parser)
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to read045

Fixed, thanks.

Mon May  7 14:25:14 BST 2007  Simon Marlow <[email protected]>
  * FIX: #1253 (Can't use non-layout at top level)

comment:4 Changed 7 years ago by igloo

  • Milestone changed from 6.8 branch to 6.8.1

comment:5 Changed 7 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:6 Changed 7 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.