Skip to content

hsc2hs --cross-compile does not handle negative #enum

#define NAME -1

data SomeType = SomeCons Integer

#{enum SomeType, SomeCons, NAME}

Output with hsc2hs or even hsc2hs --cross-safe :

{-# OPTIONS_GHC -optc-DNAME=-1 #-}
{-# LINE 1 "t.hsc" #-}

{-# LINE 2 "t.hsc" #-}

data SomeType = SomeCons Integer

name :: SomeType
name = SomeCons (-1)

{-# LINE 6 "t.hsc" #-}

Output with hsc2hs --cross-compile:

{-# LINE 1 "t.hsc" #-}
#line 1 "t.hsc"
#define NAME -1

{-# LINE 2 "t.hsc" #-}

data SomeType = SomeCons Integer

name :: SomeType
name = SomeCons -1

{-# LINE 6 "t.hsc" #-}

Which produces a compiler error.

Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component hsc2hs
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information