#5664: Missing checks for FFI declaration types ---------------------------------+------------------------------------------ Reporter: simonmar | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.6.1 Component: Compiler (FFI) | Version: 7.2.1 Keywords: | Testcase: Blockedby: | Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: GHC accepts invalid program ---------------------------------+------------------------------------------ A `foreign import "wrapper"` should have the form `f -> IO (FunPtr f)`, and a `foreign import "dynamic"` should have the form `FunPtr f -> f`. GHC currently lacks these checks; the type argument to the `FunPtr` is ignored in both cases.
Ian Lynagh's example is below; we should be rejecting `mkFun2` and `mkCallback2`. {{{ module A where import Foreign import Foreign.C data D = D foreign import ccall "dynamic" mkFun1 :: FunPtr (CInt -> IO ()) -> (CInt -> IO ()) foreign import ccall "dynamic" mkFun2 :: FunPtr (D -> IO ()) -> (CInt -> IO ()) foreign import ccall "wrapper" mkCallBack1 :: IO () -> IO (FunPtr (IO ())) foreign import ccall "wrapper" mkCallBack2 :: IO () -> IO (FunPtr D) }}} -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5664> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs