[GHC] #13332: Report unrecognized pragmas earlier

GHC ghc-devs at haskell.org
Mon Mar 13 00:42:25 UTC 2017


#13332: Report unrecognized pragmas earlier
-------------------------------------+-------------------------------------
        Reporter:  crockeea          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.2
      Resolution:                    |             Keywords:  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Poor/confusing    |  Unknown/Multiple
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by ThreeFx):

 Replying to [comment:2 richardfung]:
 > Hi! I'd like to try my hand at this but was hoping someone could give me
 some guidance.
 >
 > From my looking so far, it would appear that the current error message
 is from somewhere in the typechecker (smallerMsg) while the warning we
 want to show up is in the Lexer.
 >
 > I would have expected the warning in the lexer to show up first though
 since presumably the lexer runs before the typechecker. Could anyone give
 me a pointer to where I should look to understand what the issue is?

 You're correct that the lexer runs before the type checker - after all,
 you need to know what to typecheck.

 I suspect that `{-# LANUGAGE UndecidableInstances #-}` is not parsed as
 pragma but as nested comment. In order to verify this I would look at the
 lexer and see if this is actually the case. If it isn't, definitely check
 what this actually gets lexed as - too bad there is no `-ddump-lexed`
 option.

 If it is, I'd probably consider adding a lexing warning for unrecognized
 pragma keywords (`LANGUAGE`, `OPTIONS_GHC`, ...). Maybe this could also be
 extended to all pragmas, not only file headers.

 Anyway this may be completely wrong - it's just my opinion on where to
 start. Happy hacking!

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13332#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list