summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Eisenberg <rae@cs.brynmawr.edu>2018-11-05 11:01:47 -0500
committerRichard Eisenberg <rae@cs.brynmawr.edu>2018-11-05 13:52:31 -0500
commit72b82343b79365dc74ffafb345dd33499a7fd394 (patch)
tree8e13bd77ecd62f2f72201fba1a07763d4d3cfb90
parent1a3b9bd0b674ad16a41b942c738b8f34564bcd8d (diff)
downloadhaskell-72b82343b79365dc74ffafb345dd33499a7fd394.tar.gz
Fix #15859 by checking, not assuming, an ArgFlag
We thought that visible dependent quantification was impossible in terms, but Iceland Jack discovered otherwise in #15859. This fixes an ASSERT failure that arose. test case: dependent/should_fail/T15859
-rw-r--r--compiler/typecheck/TcExpr.hs10
-rw-r--r--testsuite/tests/dependent/should_fail/T15859.stderr6
-rw-r--r--testsuite/tests/dependent/should_fail/all.T1
3 files changed, 11 insertions, 6 deletions
diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs
index f27922f023..a087917240 100644
--- a/compiler/typecheck/TcExpr.hs
+++ b/compiler/typecheck/TcExpr.hs
@@ -1329,14 +1329,12 @@ tcArgs fun orig_fun_ty fun_orig orig_args herald
= do { (wrap1, upsilon_ty) <- topInstantiateInferred fun_orig fun_ty
-- wrap1 :: fun_ty "->" upsilon_ty
; case tcSplitForAllTy_maybe upsilon_ty of
- Just (tvb, inner_ty) ->
+ Just (tvb, inner_ty)
+ | binderArgFlag tvb == Specified ->
+ -- It really can't be Inferred, because we've just instantiated those
+ -- But, oddly, it might just be Required. See #15859.
do { let tv = binderVar tvb
- vis = binderArgFlag tvb
kind = tyVarKind tv
- ; MASSERT2( vis == Specified
- , (vcat [ ppr fun_ty, ppr upsilon_ty, ppr tvb
- , ppr inner_ty, pprTyVar tv
- , ppr vis ]) )
; ty_arg <- tcHsTypeApp hs_ty_arg kind
; inner_ty <- zonkTcType inner_ty
diff --git a/testsuite/tests/dependent/should_fail/T15859.stderr b/testsuite/tests/dependent/should_fail/T15859.stderr
new file mode 100644
index 0000000000..e4794048b7
--- /dev/null
+++ b/testsuite/tests/dependent/should_fail/T15859.stderr
@@ -0,0 +1,6 @@
+
+T15859.hs:13:5: error:
+ • Cannot apply expression of type ‘forall k -> k -> *’
+ to a visible type argument ‘Int’
+ • In the expression: (undefined :: KindOf A) @Int
+ In an equation for ‘a’: a = (undefined :: KindOf A) @Int
diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T
index d76fc35fc7..f1272200ba 100644
--- a/testsuite/tests/dependent/should_fail/all.T
+++ b/testsuite/tests/dependent/should_fail/all.T
@@ -38,3 +38,4 @@ test('T15591c', normal, compile_fail, [''])
test('T15743c', normal, compile_fail, [''])
test('T15743d', normal, compile_fail, [''])
test('T15825', normal, compile_fail, [''])
+test('T15859', normal, compile_fail, [''])