[commit: ghc] master: Fix #15859 by checking, not assuming, an ArgFlag (72b8234)

git at git.haskell.org git at git.haskell.org
Mon Nov 5 18:52:51 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/72b82343b79365dc74ffafb345dd33499a7fd394/ghc

>---------------------------------------------------------------

commit 72b82343b79365dc74ffafb345dd33499a7fd394
Author: Richard Eisenberg <rae at cs.brynmawr.edu>
Date:   Mon Nov 5 11:01:47 2018 -0500

    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


>---------------------------------------------------------------

72b82343b79365dc74ffafb345dd33499a7fd394
 compiler/typecheck/TcExpr.hs                        | 10 ++++------
 testsuite/tests/dependent/should_fail/T15859.stderr |  6 ++++++
 testsuite/tests/dependent/should_fail/all.T         |  1 +
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs
index f27922f..a087917 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 0000000..e479404
--- /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 d76fc35..f127220 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, [''])



More information about the ghc-commits mailing list