[GHC] #3806: Type checking errors in foreign declarations reported at wrong locations

GHC trac at galois.com
Mon Jan 4 20:38:36 EST 2010


#3806: Type checking errors in foreign declarations reported at wrong locations
---------------------------------+------------------------------------------
    Reporter:  asuffield         |       Owner:              
        Type:  bug               |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:  6.12.1            |    Keywords:              
          Os:  Unknown/Multiple  |    Testcase:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3806>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list