hsc2hs does not handle single quotes properly
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:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
data Foo = Foo | Bar
data Indexed ix where
Indexed :: Indexed 'Foo
main :: IO ()
main = print $ #size int
gets translated into
{-# 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.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | hsc2hs |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |