[GHC] #1215: GHC fails to respect the maximal munch rule while lexing "qualified reservedids"

Simon Marlow simonmarhaskell at gmail.com
Wed Mar 14 09:19:01 EDT 2007


Ian Lynagh wrote:
> Context if you haven't been following:
> http://hackage.haskell.org/trac/ghc/ticket/1215
> 
> On Tue, Mar 13, 2007 at 03:12:33PM -0000, GHC wrote:
>>  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.
> 
> If I understand correctly then the proposal would make e.g.
> 
>     foo = Bar.where
> 
> a syntactically valid program, but one which would be guaranteed to fail
> to compile with a not-in-scope error?
> 
> Wouldn't it be cleaner for it to be a lexical error? Unfortunately I'm
> not sure how to say this in the grammar; the best I can come up with is:
> 
>     program      ->      {lexeme | whitespace | error }
>     error        ->      [ modid . ] reservedid

Or make lexeme overlap with error, and do this:

      program  -> { lexeme_<error> | whitespace }

to make it clear that a valid program doesn't contain any error lexemes.  But 
then people might wonder why the error production doesn't contain all the 
lexical errors.

I don't really have a strong opinion here, but I lean towards not doing this, on 
the grounds that it's not strictly necessary and I'm a bit of a minimalist.  The 
compiler is already free to report the error as a lexical error if it likes.

Cheers,
	Simon


More information about the Haskell-prime mailing list