diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-08-06 20:53:49 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-08-11 22:18:03 -0400 |
commit | ab4d15898c03a5db6741feb2028488facf032fa4 (patch) | |
tree | 07cdb399592f4383d6214a957c78bad1562b9b57 /compiler | |
parent | acf537f9fefa31883b7cb28ff61b837ab7f8a44a (diff) | |
download | haskell-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.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/Tc/Gen/Sig.hs | 10 |
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 |