Ticket #1215 (closed bug: fixed)

Opened 5 years ago

Last modified 2 years ago

GHC fails to respect the maximal munch rule while lexing "qualified reservedids"

Reported by: Stefan O'Rear <stefanor@…> Owned by: simonmar
Priority: low Milestone: 6.8.1
Component: Compiler (Parser) Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The following program I believe is legal haskell 98:

module Main where

t = 2
defaul _ = return ()
main = Main.default

since Main.default is an illegal lexeme, but Main.defaul is a perfectly good qvarid. however ghci rejects it:

Bar.hs:5:12: parse error on input `default'

Something very similar to this is documented, but only in the qvarsym case. This appears fairly easy to fix using extra rules in the lexer; a flex lexer that does what I consider correct can be found at  http://members.cox.net/stefanor/h98lexer.l.

Change History

Changed 5 years ago by igloo

Technically you are right, but I think it would be better to just say in Haskell' that Main.default should not be parsed as Main.defaul t. Any objections before I close the bug?

Changed 5 years ago by simonmar

  • owner set to simonmar
  • difficulty changed from Unknown to Easy (1 hr)
  • milestone set to 6.8

Interesting. It turns out I misinterpreted the Haskell lexical syntax: GHC lexes M.default as M . default, because M.default is not a valid qvarid but I neglected to take into account the maximal munch rule.

We have an open ticket for Haskell' about this:  http://hackage.haskell.org/cgi-bin/haskell-prime/trac.cgi/wiki/QualifiedIdentifiers, which was until just now inaccurate (I've now fixed it). I propose to fix GHC in 6.8 to match the Haskell' proposal.

Changed 5 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

Fixed:

Tue Jul 24 14:04:17 BST 2007  Simon Marlow <simonmar@microsoft.com>
  * FIX #1215: GHC fails to respect the maximal munch rule while lexing "qualified reservedids"

  I didn't actually fix this to respect Haskell 98, instead I changed it
  to follow the proposal for Haskell':
  
  http://hackage.haskell.org/cgi-bin/haskell-prime/trac.cgi/wiki/QualifiedIdentifiers
  
  Rationale:
  
    - We didn't respect Haskell 98 with respect to qualified symbols either
    - The Haskell' change makes things much cleaner
    - Obeying the Haskell 98 spec literally has some unintended
      consequences (e.g. M.where must lex as "M.wher" "e")
    - Any programs that compiled before this change and do not compile
      after it were illegal according to Haskell 98 anyway.

Changed 4 years ago by igloo

  • milestone changed from 6.8 branch to 6.8.1

Changed 3 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 3 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 2 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.