Ticket #1253 (closed bug: fixed)

Opened 2 years ago

Last modified 9 months ago

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

Reported by: guest Assigned to:
Priority: normal Milestone: 6.8.1
Component: Compiler (Parser) Version: 6.6
Severity: normal Keywords:
Cc: Difficulty: Unknown
Test Case: read045 Operating System: Unknown/Multiple
Architecture: Unknown/Multiple

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

04/01/07 10:20:45 changed 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.

05/07/07 03:11:21 changed by simonmar

  • milestone changed from 6.6.2 to 6.8.

05/07/07 06:26:49 changed by simonmar

  • testcase set to read045.
  • component changed from Compiler to Compiler (Parser).
  • status changed from new to closed.
  • resolution set to fixed.

Fixed, thanks.

Mon May  7 14:25:14 BST 2007  Simon Marlow <simonmar@microsoft.com>
  * FIX: #1253 (Can't use non-layout at top level)

11/05/07 07:03:56 changed by igloo

  • milestone changed from 6.8 branch to 6.8.1.

09/30/08 08:40:11 changed by simonmar

  • architecture changed from Unknown to Unknown/Multiple.

09/30/08 08:51:16 changed by simonmar

  • os changed from Unknown to Unknown/Multiple.