Commit 8a051fca authored by Ian Lynagh's avatar Ian Lynagh

Add a test for newtypes and the FFI

You can only use newtypes in the FFI if the constructor is visible
parent 9d111543
module Ccfail004A (NInt, NIO) where
newtype NInt = NInt Int
newtype NIO a = NIO (IO a)
...@@ -6,3 +6,4 @@ test('ccfail001', only_compiler_types(['ghc']), compile_fail, ['']) ...@@ -6,3 +6,4 @@ test('ccfail001', only_compiler_types(['ghc']), compile_fail, [''])
test('ccfail002', only_compiler_types(['ghc']), compile_fail, ['']) test('ccfail002', only_compiler_types(['ghc']), compile_fail, [''])
test('ccfail003', only_compiler_types(['ghc']), compile_fail, ['']) test('ccfail003', only_compiler_types(['ghc']), compile_fail, [''])
test('T3066', only_compiler_types(['ghc']), compile_fail, ['']) test('T3066', only_compiler_types(['ghc']), compile_fail, [''])
test('ccfail004', only_compiler_types(['ghc']), multimod_compile_fail, ['ccfail004', '-v0'])
module Ccfail004 where
import Ccfail004A
-- Both these should be rejected as the NInt constructor isn't in scope
foreign import ccall f1 :: NInt -> IO Int
foreign import ccall f2 :: Int -> IO NInt
foreign import ccall f3 :: Int -> NIO Int
ccfail004.hs:7:1:
Unacceptable argument type in foreign declaration: NInt
When checking declaration:
foreign import ccall safe "static f1" f1 :: NInt -> IO Int
ccfail004.hs:8:1:
Unacceptable result type in foreign declaration: IO NInt
When checking declaration:
foreign import ccall safe "static f2" f2 :: Int -> IO NInt
ccfail004.hs:9:1:
Unacceptable result type in foreign declaration: NIO Int
When checking declaration:
foreign import ccall safe "static f3" f3 :: Int -> NIO Int
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment