summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Errors
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-26 21:09:33 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-27 10:03:43 -0400
commit8bef471aaaf3cf40d68786f06b2b9f65d3d851e7 (patch)
treee38ad6211c96ffd02be973cb2fdb887905358a7c /compiler/GHC/Tc/Errors
parent5de6be0c9120550aaa15534d0a1466018eff137a (diff)
downloadhaskell-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 'compiler/GHC/Tc/Errors')
-rw-r--r--compiler/GHC/Tc/Errors/Ppr.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs
index 95afe9c982..5778050413 100644
--- a/compiler/GHC/Tc/Errors/Ppr.hs
+++ b/compiler/GHC/Tc/Errors/Ppr.hs
@@ -782,6 +782,9 @@ instance Diagnostic TcRnMessage where
innerMsg $$ text "A foreign-imported address (via &foo) must have type (Ptr a) or (FunPtr a)"
NotSimpleUnliftedType ->
innerMsg $$ text "foreign import prim only accepts simple unlifted types"
+ NotBoxedKindAny ->
+ text "Expected kind" <+> quotes (text "Type") <+> text "or" <+> quotes (text "UnliftedType") <> comma $$
+ text "but" <+> quotes (ppr ty) <+> text "has kind" <+> quotes (ppr (typeKind ty))
ForeignDynNotPtr expected ty ->
vcat [ text "Expected: Ptr/FunPtr" <+> pprParendType expected <> comma, text " Actual:" <+> ppr ty ]
SafeHaskellMustBeInIO ->