[Git][ghc/ghc][master] 2 commits: typecheck: Drop SPECIALISE pragmas when there is no unfolding

Marge Bot gitlab at gitlab.haskell.org
Wed Aug 12 02:18:10 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00
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.

- - - - -
0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00
testsuite: Add test for #18118

- - - - -


4 changed files:

- compiler/GHC/Tc/Gen/Sig.hs
- + testsuite/tests/typecheck/should_compile/T18118.hs
- + testsuite/tests/typecheck/should_compile/T18118A.hs
- testsuite/tests/typecheck/should_compile/all.T


Changes:

=====================================
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


=====================================
testsuite/tests/typecheck/should_compile/T18118.hs
=====================================
@@ -0,0 +1,5 @@
+module T18118 (myfun) where
+
+import T18118A
+
+{-# SPECIALISE myfun :: Double #-}


=====================================
testsuite/tests/typecheck/should_compile/T18118A.hs
=====================================
@@ -0,0 +1,5 @@
+module T18118A where
+
+myfun :: a
+myfun = undefined
+


=====================================
testsuite/tests/typecheck/should_compile/all.T
=====================================
@@ -717,5 +717,6 @@ test('T17775-viewpats-a', normal, compile, [''])
 test('T17775-viewpats-b', normal, compile_fail, [''])
 test('T17775-viewpats-c', normal, compile_fail, [''])
 test('T17775-viewpats-d', normal, compile_fail, [''])
+test('T18118', normal, multimod_compile, ['T18118', '-v0'])
 test('T18412', normal, compile, [''])
 test('T18470', normal, compile, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/acf537f9fefa31883b7cb28ff61b837ab7f8a44a...0ac8c0a551619b52e0f151d6781b11dd66cf2110

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/acf537f9fefa31883b7cb28ff61b837ab7f8a44a...0ac8c0a551619b52e0f151d6781b11dd66cf2110
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200811/d430bc54/attachment-0001.html>


More information about the ghc-commits mailing list