Fix #13202 by failing more eagerly in tcRnStmt
authorRichard Eisenberg <rae@cs.brynmawr.edu>
Thu, 16 Mar 2017 15:38:05 +0000 (11:38 -0400)
committerRichard Eisenberg <rae@cs.brynmawr.edu>
Fri, 17 Mar 2017 15:23:13 +0000 (11:23 -0400)
test cases: ghci/scripts/T13202{,a}

compiler/typecheck/TcRnDriver.hs
testsuite/tests/ghci/scripts/T13202.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T13202.stderr [new file with mode: 0644]
testsuite/tests/ghci/scripts/T13202a.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T13202a.stderr [new file with mode: 0644]
testsuite/tests/ghci/scripts/all.T

index cdf3278..b02fdf5 100644 (file)
@@ -1877,6 +1877,9 @@ tcRnStmt hsc_env rdr_stmt
     zonked_expr <- zonkTopLExpr tc_expr ;
     zonked_ids  <- zonkTopBndrs bound_ids ;
 
+    failIfErrsM ;  -- we can't do the next step if there are levity polymorphism errors
+                   -- test case: ghci/scripts/T13202{,a}
+
         -- None of the Ids should be of unboxed type, because we
         -- cast them all to HValues in the end!
     mapM_ bad_unboxed (filter (isUnliftedType . idType) zonked_ids) ;
diff --git a/testsuite/tests/ghci/scripts/T13202.script b/testsuite/tests/ghci/scripts/T13202.script
new file mode 100644 (file)
index 0000000..5da0a32
--- /dev/null
@@ -0,0 +1,6 @@
+import GHC.Exts
+:set -XTypeApplications -XMagicHash -XTypeInType
+data TypeRep (a :: k) = TypeRep
+let typeRepKind = undefined :: TypeRep (a :: k) -> TypeRep k
+let typeRep = undefined :: TypeRep (a :: k)
+let x = typeRepKind (typeRep @(Maybe Int#))
diff --git a/testsuite/tests/ghci/scripts/T13202.stderr b/testsuite/tests/ghci/scripts/T13202.stderr
new file mode 100644 (file)
index 0000000..33c1945
--- /dev/null
@@ -0,0 +1,8 @@
+
+<interactive>:6:22: error:
+    • Cannot apply expression of type ‘TypeRep a0’
+      to a visible type argument ‘(Maybe Int#)’
+    • In the first argument of ‘typeRepKind’, namely
+        ‘(typeRep @(Maybe Int#))’
+      In the expression: typeRepKind (typeRep @(Maybe Int#))
+      In an equation for ‘x’: x = typeRepKind (typeRep @(Maybe Int#))
diff --git a/testsuite/tests/ghci/scripts/T13202a.script b/testsuite/tests/ghci/scripts/T13202a.script
new file mode 100644 (file)
index 0000000..107d332
--- /dev/null
@@ -0,0 +1,3 @@
+import GHC.Records
+:set -XTypeApplications -XDataKinds
+let foo = getField @"name"
diff --git a/testsuite/tests/ghci/scripts/T13202a.stderr b/testsuite/tests/ghci/scripts/T13202a.stderr
new file mode 100644 (file)
index 0000000..93bc2bb
--- /dev/null
@@ -0,0 +1,6 @@
+
+<interactive>:3:5: error:
+    • Non type-variable argument in the constraint: HasField "name" r a
+      (Use FlexibleContexts to permit this)
+    • When checking the inferred type
+        foo :: forall r a. HasField "name" r a => r -> a
index 7f03cf8..20bc5ae 100755 (executable)
@@ -248,3 +248,5 @@ test('T12447', expect_broken(12447), ghci_script, ['T12447.script'])
 test('T10249', normal, ghci_script, ['T10249.script'])
 test('T12550', normal, ghci_script, ['T12550.script'])
 test('StaticPtr', normal, ghci_script, ['StaticPtr.script'])
+test('T13202', normal, ghci_script, ['T13202.script'])
+test('T13202a', normal, ghci_script, ['T13202a.script'])