summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-08-06 20:53:49 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-11 22:18:03 -0400
commitab4d15898c03a5db6741feb2028488facf032fa4 (patch)
tree07cdb399592f4383d6214a957c78bad1562b9b57
parentacf537f9fefa31883b7cb28ff61b837ab7f8a44a (diff)
downloadhaskell-ab4d15898c03a5db6741feb2028488facf032fa4.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.
-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 7d253f079d..35f6951ae1 100644
--- a/compiler/GHC/Tc/Gen/Sig.hs
+++ b/compiler/GHC/Tc/Gen/Sig.hs
@@ -826,9 +826,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