[GHC] #11004: hsc2hs does not handle single quotes properly

GHC ghc-devs at haskell.org
Thu Oct 22 19:13:52 UTC 2015


#11004: hsc2hs does not handle single quotes properly
-------------------------------------+-------------------------------------
           Reporter:  sergv          |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  hsc2hs         |           Version:  7.10.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The tool gets confused by quotes for promoted constructors
 (https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/promotion.html
 #promotion-syntax). Here's an example:

 {{{#!hs
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE GADTs     #-}

 data Foo = Foo | Bar

 data Indexed ix where
   Indexed :: Indexed 'Foo

 main :: IO ()
 main = print $ #size int
 }}}

 gets translated into

 {{{#!hs
 {-# LINE 1 "Test.hsc" #-}
 {-# LANGUAGE DataKinds #-}
 {-# LINE 2 "Test.hsc" #-}
 {-# LANGUAGE GADTs     #-}

 data Foo = Foo | Bar

 data Indexed ix where
   Indexed :: Indexed 'Foo

 main :: IO ()
 main = print $ #size int
 }}}

 Then GHC complains about `#size`:

 {{{
 Test.hsc:10:16: parse error on input ‘#’
 }}}

 Judging from the source of utils/hsc2hs/HSCParser.hs, the tool treats
 single quotes the same way as double quotes. I.e. it looks for balanced,
 possibly multiline, strings delimited by '. At least, it seems unnecessary
 to expect newlines in that string-like structure, because character
 literals cannot contain newlines, AFAIK.

 It's interesting to note that this problem looks like a bit of an edge
 case, since highlighting in the ticket seems to be confused as well.

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


More information about the ghc-tickets mailing list