summaryrefslogtreecommitdiff
path: root/testsuite/tests/linear
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-09-24 23:13:10 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-26 13:19:00 -0400
commit160fba4aa306c0649c72a6dcd7c98d9782a0e74b (patch)
tree1d4d70dfa3463a079f9eda797e4932b90dfb6812 /testsuite/tests/linear
parentbda55fa0444310079ab89f2d28ddb8982975b646 (diff)
downloadhaskell-160fba4aa306c0649c72a6dcd7c98d9782a0e74b.tar.gz
Disallow linear types in FFI (#18472)
Diffstat (limited to 'testsuite/tests/linear')
-rw-r--r--testsuite/tests/linear/should_fail/LinearFFI.hs8
-rw-r--r--testsuite/tests/linear/should_fail/LinearFFI.stderr20
-rw-r--r--testsuite/tests/linear/should_fail/all.T1
3 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/linear/should_fail/LinearFFI.hs b/testsuite/tests/linear/should_fail/LinearFFI.hs
new file mode 100644
index 0000000000..6c6e1c562a
--- /dev/null
+++ b/testsuite/tests/linear/should_fail/LinearFFI.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE LinearTypes #-}
+module LinearFFI where -- #18472
+
+import Foreign.Ptr
+
+foreign import ccall "exp" c_exp :: Double #-> Double
+foreign import stdcall "dynamic" d8 :: FunPtr (IO Int) #-> IO Int
+foreign import ccall "wrapper" mkF :: IO () #-> IO (FunPtr (IO ()))
diff --git a/testsuite/tests/linear/should_fail/LinearFFI.stderr b/testsuite/tests/linear/should_fail/LinearFFI.stderr
new file mode 100644
index 0000000000..41dd5e66a7
--- /dev/null
+++ b/testsuite/tests/linear/should_fail/LinearFFI.stderr
@@ -0,0 +1,20 @@
+
+LinearFFI.hs:6:1: error:
+ • Unacceptable argument type in foreign declaration:
+ Linear types are not supported in FFI declarations, see #18472
+ • When checking declaration:
+ foreign import ccall safe "exp" c_exp :: Double #-> Double
+
+LinearFFI.hs:7:1: error:
+ • Unacceptable argument type in foreign declaration:
+ Linear types are not supported in FFI declarations, see #18472
+ • When checking declaration:
+ foreign import stdcall safe "dynamic" d8
+ :: FunPtr (IO Int) #-> IO Int
+
+LinearFFI.hs:8:1: error:
+ • Unacceptable argument type in foreign declaration:
+ Linear types are not supported in FFI declarations, see #18472
+ • When checking declaration:
+ foreign import ccall safe "wrapper" mkF
+ :: IO () #-> IO (FunPtr (IO ()))
diff --git a/testsuite/tests/linear/should_fail/all.T b/testsuite/tests/linear/should_fail/all.T
index 941966673c..5a79b031b6 100644
--- a/testsuite/tests/linear/should_fail/all.T
+++ b/testsuite/tests/linear/should_fail/all.T
@@ -28,3 +28,4 @@ test('LinearBottomMult', normal, compile_fail, [''])
test('LinearSequenceExpr', normal, compile_fail, [''])
test('LinearIf', normal, compile_fail, [''])
test('LinearPatternGuardWildcard', normal, compile_fail, [''])
+test('LinearFFI', normal, compile_fail, [''])