Type checking errors in foreign declarations reported at wrong locations
The following code:
{-# LANGUAGE ForeignFunctionInterface #-}
import Foreign.C.Types
foreign export ccall foo :: CInt -> IO ()
foo "x" = return ()
yields this error:
TestErr.hs:4:0:
Couldn't match expected type `CInt' against inferred type `[Char]'
In the expression: foo
When checking declaration:
foreign export ccall "foo" foo :: CInt -> IO ()
The error part is notionally correct, but the location where it is reported is wrong - it's reporting the type declaration as erroneous, while type errors would normally report the function definition.
Compare the error with a non-foreign declaration:
{-# LANGUAGE ForeignFunctionInterface #-}
import Foreign.C.Types
foo :: CInt -> IO ()
foo "x" = return ()
giving:
TestErr.hs:5:4:
Couldn't match expected type `CInt' against inferred type `[Char]'
In the pattern: "x"
In the definition of `foo': foo "x" = return ()
This is the error that I wanted to see.
Trac metadata
Trac field | Value |
---|---|
Version | 6.12.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |