Do not treat prim and javascript imports as C imports in TH and QQ
[ghc.git] / testsuite / tests / th / T10638.hs
1 {-# LANGUAGE GHCForeignImportPrim, UnliftedFFITypes, QuasiQuotes, MagicHash #-}
2
3 import Language.Haskell.TH
4 import Language.Haskell.TH.Syntax
5
6 import GHC.Exts
7
8 {-
9 the prim and javascript calling conventions do not support
10 headers and the static keyword.
11 -}
12
13 -- check that quasiquoting roundtrips succesfully and that the declaration
14 -- does not include the static keyword
15 test1 :: String
16 test1 = $(do (ds@[ForeignD (ImportF _ _ p _ _)]) <-
17 [d| foreign import prim "test1" cmm_test1 :: Int# -> Int# |]
18 addTopDecls ds
19 case p of
20 "test1" -> return (LitE . stringL $ p)
21 _ -> error $ "unexpected value: " ++ show p
22 )
23
24 -- check that constructed prim imports with the static keyword are rejected
25 test2 :: String
26 test2 = $(do t <- [t| Int# -> Int# |]
27 cmm_test2 <- newName "cmm_test2"
28 addTopDecls
29 [ForeignD (ImportF Prim Safe "static test2" cmm_test2 t)]
30 [| test1 |]
31 )