Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,243
    • Issues 5,243
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 567
    • Merge requests 567
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #5664
Closed
Open
Issue created Nov 28, 2011 by Simon Marlow@simonmarDeveloper

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking