diff options
author | sheaf <sam.derbyshire@gmail.com> | 2022-04-26 21:09:33 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-04-27 10:03:43 -0400 |
commit | 8bef471aaaf3cf40d68786f06b2b9f65d3d851e7 (patch) | |
tree | e38ad6211c96ffd02be973cb2fdb887905358a7c /testsuite/tests/ffi/should_fail | |
parent | 5de6be0c9120550aaa15534d0a1466018eff137a (diff) | |
download | haskell-8bef471aaaf3cf40d68786f06b2b9f65d3d851e7.tar.gz |
Ensure that Any is Boxed in FFI imports/exports
We should only accept the type `Any` in foreign import/export
declarations when it has type `Type` or `UnliftedType`.
This patch adds a kind check, and a special error message triggered by
occurrences of `Any` in foreign import/export declarations at other
kinds.
Fixes #21305
Diffstat (limited to 'testsuite/tests/ffi/should_fail')
-rw-r--r-- | testsuite/tests/ffi/should_fail/T21305_fail.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_fail/T21305_fail.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/ffi/should_fail/all.T | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_fail/T21305_fail.hs b/testsuite/tests/ffi/should_fail/T21305_fail.hs new file mode 100644 index 0000000000..c6f8d6863a --- /dev/null +++ b/testsuite/tests/ffi/should_fail/T21305_fail.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE DataKinds, GHCForeignImportPrim #-} + +module T21305_fail where + +import GHC.Exts + +foreign import prim "f" f :: Any @(TYPE IntRep) -> Any diff --git a/testsuite/tests/ffi/should_fail/T21305_fail.stderr b/testsuite/tests/ffi/should_fail/T21305_fail.stderr new file mode 100644 index 0000000000..d2ed006df8 --- /dev/null +++ b/testsuite/tests/ffi/should_fail/T21305_fail.stderr @@ -0,0 +1,7 @@ + +T21305_fail.hs:7:1: error: + • Unacceptable argument type in foreign declaration: + Expected kind ‘Type’ or ‘UnliftedType’, + but ‘Any’ has kind ‘TYPE 'IntRep’ + • When checking declaration: + foreign import prim safe "f" f :: Any @(TYPE IntRep) -> Any diff --git a/testsuite/tests/ffi/should_fail/all.T b/testsuite/tests/ffi/should_fail/all.T index 24210dcca6..9080282782 100644 --- a/testsuite/tests/ffi/should_fail/all.T +++ b/testsuite/tests/ffi/should_fail/all.T @@ -17,6 +17,7 @@ test('T7243', normal, compile_fail, ['']) test('T10461', normal, compile_fail, ['']) test('T16702', normal, compile_fail, ['']) test('T20116', normal, compile_fail, ['']) +test('T21305_fail', normal, compile_fail, ['']) # UnsafeReenter tests implementation of an undefined behavior (calling Haskell # from an unsafe foreign function) and only makes sense in non-threaded way |