summaryrefslogtreecommitdiff
path: root/testsuite/tests/ffi
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-07-25 16:22:21 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-07-25 16:22:43 +0100
commit92587bfefea2b78f89bcdad27e0da5711463fd1b (patch)
tree571c7d97dfd53c13b0927110c869e7419b5c94f3 /testsuite/tests/ffi
parent2070a8f3565babed12942d2fee517421ee776ad6 (diff)
downloadhaskell-92587bfefea2b78f89bcdad27e0da5711463fd1b.tar.gz
Refactor FFI error messages
This patch was provoked by Trac #5610, which I finally got a moment to look at. In the end I added a new data type ErrUtils.Validity, data Validity = IsValid -- Everything is fine | NotValid MsgDoc -- A problem, and some indication of why with some suitable combinators, and used it where appropriate (which touches quite a few modules). The main payoff is that error messages improve for FFI type validation.
Diffstat (limited to 'testsuite/tests/ffi')
-rw-r--r--testsuite/tests/ffi/should_fail/T3066.stderr7
-rw-r--r--testsuite/tests/ffi/should_fail/T5664.stderr7
-rw-r--r--testsuite/tests/ffi/should_fail/T7506.stderr5
-rw-r--r--testsuite/tests/ffi/should_fail/ccfail001.stderr7
-rw-r--r--testsuite/tests/ffi/should_fail/ccfail002.stderr6
-rw-r--r--testsuite/tests/ffi/should_fail/ccfail003.stderr6
-rw-r--r--testsuite/tests/ffi/should_fail/ccfail004.stderr22
-rw-r--r--testsuite/tests/ffi/should_fail/ccfail005.stderr6
8 files changed, 43 insertions, 23 deletions
diff --git a/testsuite/tests/ffi/should_fail/T3066.stderr b/testsuite/tests/ffi/should_fail/T3066.stderr
index 2bbaf629c7..e6d292d4ec 100644
--- a/testsuite/tests/ffi/should_fail/T3066.stderr
+++ b/testsuite/tests/ffi/should_fail/T3066.stderr
@@ -1,6 +1,7 @@
T3066.hs:6:1:
- Unacceptable argument type in foreign declaration: forall u. Ptr ()
+ Unacceptable argument type in foreign declaration:
+ ‘forall u. Ptr ()’ is not a data type
When checking declaration:
- foreign import ccall safe "static bla" bla
- :: (forall u. X u) -> IO ()
+ foreign import ccall safe "static bla" bla
+ :: (forall u. X u) -> IO ()
diff --git a/testsuite/tests/ffi/should_fail/T5664.stderr b/testsuite/tests/ffi/should_fail/T5664.stderr
index 30bd017a1d..c1652c2288 100644
--- a/testsuite/tests/ffi/should_fail/T5664.stderr
+++ b/testsuite/tests/ffi/should_fail/T5664.stderr
@@ -1,13 +1,16 @@
T5664.hs:15:1:
Unacceptable argument type in foreign declaration:
- FunPtr (D -> IO ())
+ Expected: Ptr/FunPtr (Int32 -> IO ()),
+ Actual: FunPtr (D -> IO ())
When checking declaration:
foreign import ccall safe "dynamic" mkFun3
:: FunPtr (D -> IO ()) -> CInt -> IO ()
T5664.hs:24:1:
- Unacceptable result type in foreign declaration: IO (FunPtr (IO D))
+ Unacceptable result type in foreign declaration:
+ Expected: Ptr/FunPtr (IO Int32),
+ Actual: FunPtr (IO D)
When checking declaration:
foreign import ccall safe "wrapper" mkCallBack3
:: IO CInt -> IO (FunPtr (IO D))
diff --git a/testsuite/tests/ffi/should_fail/T7506.stderr b/testsuite/tests/ffi/should_fail/T7506.stderr
index e8e95a9275..dd893df155 100644
--- a/testsuite/tests/ffi/should_fail/T7506.stderr
+++ b/testsuite/tests/ffi/should_fail/T7506.stderr
@@ -1,7 +1,8 @@
T7506.hs:6:1:
- Unacceptable type in foreign declaration: Int -> IO ()
- A foreign-imported address (via &foo) must have type (Ptr a) or (FunPtr a)
+ Unacceptable type in foreign declaration:
+ ‘Int -> IO ()’ cannot be marshalled in a foreign call
+ A foreign-imported address (via &foo) must have type (Ptr a) or (FunPtr a)
When checking declaration:
foreign import ccall safe "static stdio.h &putchar" c_putchar
:: Int -> IO ()
diff --git a/testsuite/tests/ffi/should_fail/ccfail001.stderr b/testsuite/tests/ffi/should_fail/ccfail001.stderr
index 813c5d187c..e890041b02 100644
--- a/testsuite/tests/ffi/should_fail/ccfail001.stderr
+++ b/testsuite/tests/ffi/should_fail/ccfail001.stderr
@@ -1,6 +1,7 @@
ccfail001.hs:10:1:
- Unacceptable result type in foreign declaration: State# RealWorld
+ Unacceptable result type in foreign declaration:
+ ‘State# RealWorld’ cannot be marshalled in a foreign call
When checking declaration:
- foreign import ccall safe "static foo" foo
- :: Int -> State# RealWorld
+ foreign import ccall safe "static foo" foo
+ :: Int -> State# RealWorld
diff --git a/testsuite/tests/ffi/should_fail/ccfail002.stderr b/testsuite/tests/ffi/should_fail/ccfail002.stderr
index dfff4272cd..309fa521d2 100644
--- a/testsuite/tests/ffi/should_fail/ccfail002.stderr
+++ b/testsuite/tests/ffi/should_fail/ccfail002.stderr
@@ -1,7 +1,7 @@
ccfail002.hs:10:1:
Unacceptable result type in foreign declaration:
- (# Int#, Int#, Int# #)
+ ‘(# Int#, Int#, Int# #)’ cannot be marshalled in a foreign call
When checking declaration:
- foreign import ccall unsafe "static foo" foo
- :: Int# -> Int# -> Int# -> (# Int#, Int#, Int# #)
+ foreign import ccall unsafe "static foo" foo
+ :: Int# -> Int# -> Int# -> (# Int#, Int#, Int# #)
diff --git a/testsuite/tests/ffi/should_fail/ccfail003.stderr b/testsuite/tests/ffi/should_fail/ccfail003.stderr
index 4ce9db572d..6afdd7678f 100644
--- a/testsuite/tests/ffi/should_fail/ccfail003.stderr
+++ b/testsuite/tests/ffi/should_fail/ccfail003.stderr
@@ -1,10 +1,12 @@
ccfail003.hs:7:1:
- Unacceptable argument type in foreign declaration: Int#
+ Unacceptable argument type in foreign declaration:
+ ‘Int#’ cannot be marshalled in a foreign call
When checking declaration:
foreign export ccall "foo" foo :: Int# -> IO ()
ccfail003.hs:10:1:
- Unacceptable result type in foreign declaration: Int#
+ Unacceptable result type in foreign declaration:
+ ‘Int#’ cannot be marshalled in a foreign call
When checking declaration:
foreign export ccall "bar" bar :: Int -> Int#
diff --git a/testsuite/tests/ffi/should_fail/ccfail004.stderr b/testsuite/tests/ffi/should_fail/ccfail004.stderr
index cce4258911..f54ac91aa3 100644
--- a/testsuite/tests/ffi/should_fail/ccfail004.stderr
+++ b/testsuite/tests/ffi/should_fail/ccfail004.stderr
@@ -1,26 +1,36 @@
-
ccfail004.hs:9:1:
- Unacceptable argument type in foreign declaration: NInt
+ Unacceptable argument type in foreign declaration:
+ ‘NInt’ cannot be marshalled in a foreign call
+ because its data construtor is not in scope
+ Possible fix: import the data constructor to bring it into scope
When checking declaration:
foreign import ccall safe "static f1" f1 :: NInt -> IO Int
ccfail004.hs:10:1:
- Unacceptable result type in foreign declaration: IO NInt
+ Unacceptable result type in foreign declaration:
+ ‘NInt’ cannot be marshalled in a foreign call
+ because its data construtor is not in scope
+ Possible fix: import the data constructor to bring it into scope
When checking declaration:
foreign import ccall safe "static f2" f2 :: Int -> IO NInt
ccfail004.hs:11:1:
- Unacceptable result type in foreign declaration: NIO Int
+ Unacceptable result type in foreign declaration:
+ ‘NIO Int’ cannot be marshalled in a foreign call
+ because the data construtor for ‘NIO’ is not in scope
+ Possible fix: import the data constructor to bring it into scope
When checking declaration:
foreign import ccall safe "static f3" f3 :: Int -> NIO Int
ccfail004.hs:14:1:
- Unacceptable argument type in foreign declaration: [NT]
+ Unacceptable argument type in foreign declaration:
+ ‘[NT]’ cannot be marshalled in a foreign call
When checking declaration:
foreign import ccall safe "static f4" f4 :: NT -> IO ()
ccfail004.hs:15:1:
- Unacceptable result type in foreign declaration: IO [NT]
+ Unacceptable result type in foreign declaration:
+ ‘[NT]’ cannot be marshalled in a foreign call
When checking declaration:
foreign import ccall safe "static f5" f5 :: IO NT
diff --git a/testsuite/tests/ffi/should_fail/ccfail005.stderr b/testsuite/tests/ffi/should_fail/ccfail005.stderr
index 0d96fe91e3..413faa702c 100644
--- a/testsuite/tests/ffi/should_fail/ccfail005.stderr
+++ b/testsuite/tests/ffi/should_fail/ccfail005.stderr
@@ -1,10 +1,12 @@
ccfail005.hs:14:1:
- Unacceptable argument type in foreign declaration: D
+ Unacceptable argument type in foreign declaration:
+ ‘D’ cannot be marshalled in a foreign call
When checking declaration:
foreign import ccall safe "static f1" f1 :: F Bool
ccfail005.hs:15:1:
- Unacceptable result type in foreign declaration: IO D
+ Unacceptable result type in foreign declaration:
+ ‘D’ cannot be marshalled in a foreign call
When checking declaration:
foreign import ccall safe "static f2" f2 :: F Char