Ticket #3995 (new bug)

Opened 3 years ago

Last modified 3 years ago

Comment delimiters ignored inside compiler pragma

Reported by: heatsink Owned by:
Priority: normal Milestone: _|_
Component: Compiler (Parser) Version: 6.10.4
Keywords: pragma comment Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Other Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

GHC accepts some pragmas that are not valid comments because of embedded comment delimiters. If the delimiters are hidden inside an embedded comment or string, they are not recognized by the parser, but they should be according to the Haskell report. For example, the following has one opening and three closing comment delimiters, but is accepted by the parser.

{-# RULES
 "-}" id 0 = 0
 -- -}
 #-}

Change History

Changed 3 years ago by igloo

  • owner set to igloo
  • milestone set to 6.14.1

Hmm, personally I would say the language definition ought to have {-# and #-} as lexemes.

Changed 3 years ago by igloo

Actually, having thought about it more, I think you are right and it is just a straight GHC bug.

Changed 3 years ago by simonmar

  • milestone changed from 6.14.1 to _|_

Good point, but awkward to fix, and unlikely to be a problem often in practice.

Changed 3 years ago by igloo

  • owner igloo deleted
Note: See TracTickets for help on using tickets.