[Git][ghc/ghc][master] Fix typed holes causing linearity errors (#18491)

Marge Bot gitlab at gitlab.haskell.org
Sat Sep 26 01:15:20 UTC 2020



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


Commits:
6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00
Fix typed holes causing linearity errors (#18491)

- - - - -


3 changed files:

- compiler/GHC/Tc/Gen/Expr.hs
- + testsuite/tests/linear/should_compile/LinearHole.hs
- testsuite/tests/linear/should_compile/all.T


Changes:

=====================================
compiler/GHC/Tc/Gen/Expr.hs
=====================================
@@ -198,6 +198,8 @@ tcExpr e@(HsUnboundVar _ occ) res_ty
        ; name <- newSysName occ
        ; let ev = mkLocalId name Many ty
        ; emitNewExprHole occ ev ty
+       ; tcEmitBindingUsage bottomUE   -- Holes fit any usage environment
+                                       -- (#18491)
        ; tcWrapResultO (UnboundOccurrenceOf occ) e
                        (HsUnboundVar ev occ) ty res_ty }
 


=====================================
testsuite/tests/linear/should_compile/LinearHole.hs
=====================================
@@ -0,0 +1,7 @@
+{-# LANGUAGE LinearTypes #-}
+{-# OPTIONS_GHC -fdefer-typed-holes -Wno-typed-holes #-}
+
+module LinearHole where  -- #18491
+
+f :: Int #-> Bool #-> Char
+f x y = _1


=====================================
testsuite/tests/linear/should_compile/all.T
=====================================
@@ -35,3 +35,4 @@ test('MultConstructor', expect_broken(broken_multiplicity_syntax), compile, ['']
 test('LinearLetRec', expect_broken(405), compile, ['-O -dlinear-core-lint'])
 test('LinearTH1', normal, compile, [''])
 test('LinearTH2', expect_broken(broken_multiplicity_syntax), compile, [''])
+test('LinearHole', normal, compile, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a7dae4badcea5b3519005cf4e5fbf15f7e5df59

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a7dae4badcea5b3519005cf4e5fbf15f7e5df59
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/20200925/f9f0ea30/attachment.html>


More information about the ghc-commits mailing list