Ticket #5664 (closed bug: fixed)
Missing checks for FFI declaration types
| Reported by: | simonmar | Owned by: | pcapriotti |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.6.1 |
| Component: | Compiler (FFI) | Version: | 7.2.1 |
| Keywords: | Cc: | dterei | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | GHC accepts invalid program | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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)
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

