summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-09-24 21:02:09 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-25 21:15:14 -0400
commit6a7dae4badcea5b3519005cf4e5fbf15f7e5df59 (patch)
treeeb97e0fbb778f6600e674fe2f5f9a8bd8bd7c6d2
parent04bc50b3c8e40387a0d0f090ea23cd68923f1834 (diff)
downloadhaskell-6a7dae4badcea5b3519005cf4e5fbf15f7e5df59.tar.gz
Fix typed holes causing linearity errors (#18491)
-rw-r--r--compiler/GHC/Tc/Gen/Expr.hs2
-rw-r--r--testsuite/tests/linear/should_compile/LinearHole.hs7
-rw-r--r--testsuite/tests/linear/should_compile/all.T1
3 files changed, 10 insertions, 0 deletions
diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs
index 9d40225a55..3b4aa4ec20 100644
--- a/compiler/GHC/Tc/Gen/Expr.hs
+++ b/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 }
diff --git a/testsuite/tests/linear/should_compile/LinearHole.hs b/testsuite/tests/linear/should_compile/LinearHole.hs
new file mode 100644
index 0000000000..e4c5181d9e
--- /dev/null
+++ b/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
diff --git a/testsuite/tests/linear/should_compile/all.T b/testsuite/tests/linear/should_compile/all.T
index 8b11b9ccb9..5a4b47c269 100644
--- a/testsuite/tests/linear/should_compile/all.T
+++ b/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, [''])