[GHC] #12391: LANGUAGE CPP messes up parsing when backslash like \\ is at end of line (eol)

GHC ghc-devs at haskell.org
Sun Jul 31 06:21:13 UTC 2016


#12391: LANGUAGE CPP messes up parsing when backslash like \\ is at end of line
(eol)
-------------------------------------+-------------------------------------
        Reporter:  andreas.abel      |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
  (Parser)                           |
      Resolution:                    |             Keywords:  CPP
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by andreas.abel):

 This makes for a nice exploit:
 {{{#!hs
 -- {-# LANGUAGE CPP #-}
 {-# LANGUAGE TemplateHaskell #-} -- for quickCheckAll

 import Test.QuickCheck.All

 infixl 6 %
 infixl 6 %\  -- Was this the correct fixity?

 (%) :: Int -> Int -> Int
 x % y = x - y

 (%\) :: Int -> Int -> Int
 x %\ y = (x + 1) - y

 prop_by_def x y =
   (x + 1) %
     y
   == x %\
        y

 return [] -- TH hack

 main = $quickCheckAll
 }}}
 Uncomment the CPP pragma and quickCheck again!

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


More information about the ghc-tickets mailing list