summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-08-06 20:53:49 -0400
committerBen Gamari <ben@smart-cactus.org>2020-09-17 19:46:29 -0400
commit8dcbbeec2eb325a2a411af6ce82fa539efbc807e (patch)
tree488bb6dd4ea479138897516ce738759d44d33c98
parenteae6f239db9d71143aaea4c7e83990c59874ab96 (diff)
downloadhaskell-8dcbbeec2eb325a2a411af6ce82fa539efbc807e.tar.gz
typecheck: Drop SPECIALISE pragmas when there is no unfolding
Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. (cherry picked from commit 708e374a8bf108999c11b6cf59c7d27677ed24a8)
-rw-r--r--compiler/GHC/Tc/Gen/Sig.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Gen/Sig.hs b/compiler/GHC/Tc/Gen/Sig.hs
index aee53733f4..7de3832bb6 100644
--- a/compiler/GHC/Tc/Gen/Sig.hs
+++ b/compiler/GHC/Tc/Gen/Sig.hs
@@ -825,9 +825,13 @@ tcImpPrags prags
tcImpSpec :: (Name, Sig GhcRn) -> TcM [TcSpecPrag]
tcImpSpec (name, prag)
= do { id <- tcLookupId name
- ; unless (isAnyInlinePragma (idInlinePragma id))
- (addWarnTc NoReason (impSpecErr name))
- ; tcSpecPrag id prag }
+ ; if isAnyInlinePragma (idInlinePragma id)
+ then tcSpecPrag id prag
+ else do { addWarnTc NoReason (impSpecErr name)
+ ; return [] } }
+ -- If there is no INLINE/INLINABLE pragma there will be no unfolding. In
+ -- that case, just delete the SPECIALISE pragma altogether, lest the
+ -- desugarer fall over because it can't find the unfolding. See #18118.
impSpecErr :: Name -> SDoc
impSpecErr name