Comments only
authorSimon Peyton Jones <simonpj@microsoft.com>
Mon, 15 Feb 2016 08:46:36 +0000 (08:46 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Mon, 15 Feb 2016 08:47:31 +0000 (08:47 +0000)
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcSimplify.hs
testsuite/tests/typecheck/should_fail/T11541.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T11541.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T

index 5f2c908..e97e3c5 100644 (file)
@@ -134,7 +134,12 @@ reportUnsolved wanted
        ; getTcEvBinds binds_var }
 
 -- | Report *all* unsolved goals as errors, even if -fdefer-type-errors is on
+-- However, do not make any evidence bindings, because we don't
+-- have any convenient place to put them.
 -- See Note [Deferring coercion errors to runtime]
+-- Used by solveEqualities for kind equalities
+--      (see Note [Fail fast on kind errors] in TcSimplify]
+-- and for simplifyDefault.
 reportAllUnsolved :: WantedConstraints -> TcM ()
 reportAllUnsolved wanted
   = report_unsolved Nothing False TypeError HoleError HoleError wanted
@@ -240,11 +245,15 @@ data ReportErrCtxt
                                        --   (innermost first)
                                        -- ic_skols and givens are tidied, rest are not
           , cec_tidy  :: TidyEnv
+
           , cec_binds :: Maybe EvBindsVar
-                         -- Nothinng <=> Report all errors, including holes; no bindings
-                         -- Just ev  <=> make some errors (depending on cec_defer)
-                         --              into warnings, and emit evidence bindings
-                         --              into 'ev' for unsolved constraints
+                         -- Nothing <=> Report all errors, including holes
+                         --             Do not add any evidence bindings, because
+                         --             we have no convenient place to put them
+                         --             See TcErrors.reportAllUnsolved
+                         -- Just ev <=> make some errors (depending on cec_defer)
+                         --             into warnings, and emit evidence bindings
+                         --             into 'ev' for unsolved constraints
 
           , cec_errors_as_warns :: Bool   -- Turn all errors into warnings
                                           -- (except for Holes, which are
index 8cc9b49..be07358 100644 (file)
@@ -188,11 +188,15 @@ defaultCallStacks wanteds
 solveEqualities is used to solve kind equalities when kind-checking
 user-written types. If solving fails we should fail outright, rather
 than just accumulate an error message, for two reasons:
+
   * A kind-bogus type signature may cause a cascade of knock-on
     errors if we let it pass
 
-  * More seriously, if we don't solve a constraint we'll be left
-    with a type that has a coercion hole in it, something like
+  * More seriously, we don't have a convenient term-level place to add
+    deferred bindings for unsolved kind-equality constraints, so we
+    don't build evidence bindings (by usine reportAllUnsolved). That
+    means that we'll be left with with a type that has coercion holes
+    in it, something like
            <type> |> co-hole
     where co-hole is not filled in.  Eeek!  That un-filled-in
     hole actually causes GHC to crash with "fvProv falls into a hole"
diff --git a/testsuite/tests/typecheck/should_fail/T11541.hs b/testsuite/tests/typecheck/should_fail/T11541.hs
new file mode 100644 (file)
index 0000000..56f41f3
--- /dev/null
@@ -0,0 +1,8 @@
+module T11541 where
+
+g :: Ord k => k -> v -> ()
+g k v = ()
+
+f x y =
+   let m = min x y
+   in  g m foo
diff --git a/testsuite/tests/typecheck/should_fail/T11541.stderr b/testsuite/tests/typecheck/should_fail/T11541.stderr
new file mode 100644 (file)
index 0000000..5669c9c
--- /dev/null
@@ -0,0 +1,2 @@
+\r
+T11541.hs:8:12: error: Variable not in scope: foo\r
index bf8d7c7..69df866 100644 (file)
@@ -406,3 +406,4 @@ test('T11355', normal, compile_fail, [''])
 test('T11464', normal, compile_fail, [''])
 test('T11473', expect_broken(11473), compile_fail, [''])
 test('T11563', normal, compile_fail, [''])
+test('T11541', normal, compile_fail, [''])