Skip to content

Template Haskell generates invalid code for import foreign address declaration

For example, splicing ForeignD (ImportF CCall Unsafe "&" (mkName "foo") (AppT (ConT ''Ptr) (ConT ''()))) GHC generates code equivalent to foreign import ccall unsafe "foo" foo :: Ptr () but not foreign import ccall unsafe "&" foo :: Ptr ().

-ddump-splices shows something like foreign import ccall unsafe "static & &foo" foo :: Ptr (). GHC can splice this (and produce bogus code) but can not compile this code literally, generating invalid assembler name _&foo for foo.

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