Opened 4 years ago

Last modified 2 months ago

#4931 new bug

hsc2hs emits invalid OPTIONS_GHC pragmas

Reported by: awson Owned by:
Priority: low Milestone: 7.12.1
Component: hsc2hs Version: 7.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:


If I write

#define FOO "bar baz"

in my hsc code, hsc2hs emits

{-# OPTIONS_GHC -optc-DFOO="bar baz" #-}

which GHC refuses to compile.

For my local hsc2hs I didn't bother with goodForOptD AI and have removed outOption for "define" key in outSpecial altogether.

Change History (6)

comment:1 Changed 4 years ago by igloo

  • Milestone set to 7.2.1

Thanks for the report.

comment:2 Changed 3 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1
  • Priority changed from normal to low

comment:3 Changed 2 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:4 Changed 8 months ago by thoughtpolice

  • Milestone changed from 7.6.2 to 7.10.1

Moving to 7.10.1.

comment:5 Changed 4 months ago by thomie

  • difficulty set to Unknown

There are 2 possible solutions:

  • in hsc2hs, ignore #define NAME VALUE when VALUE contains a space. This could be done in the function outHeaderHs in utils/hsc2hs/C.hs as mentioned by @awson. I'm not sure this is good idea (wouldn't an error be better?), but note that #defines where NAME contains a '(' are currently also ignored.
  • when using the OPTIONS pragma -Dsymbol=value, accept spaces inside value when value is quoted. This would need to be done in the function getOptions' in compiler/main/HeaderInfo.hs, by changing (words str) to something more complicated. Note that GHC already accepts spaces in value when the option is passed as a command line argument: -D'"FOO BAR"'

comment:6 Changed 2 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

Note: See TracTickets for help on using tickets.