Missing checks for FFI declaration types
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)
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.2.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (FFI) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |