[commit: ghc] master: Add a missing addDeferredBinding (2f9f1f8)

git at git.haskell.org git at git.haskell.org
Thu Apr 6 11:34:26 UTC 2017


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2f9f1f86849ebc18af409c9b3fd809c9cd464021/ghc

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

commit 2f9f1f86849ebc18af409c9b3fd809c9cd464021
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Apr 5 13:39:51 2017 +0100

    Add a missing addDeferredBinding
    
    I'd forgotten to add deferred bindings for user type
    errors.  Fixes Trac #13487.


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

2f9f1f86849ebc18af409c9b3fd809c9cd464021
 compiler/typecheck/TcErrors.hs                      |  3 ++-
 testsuite/tests/typecheck/should_fail/T13487.hs     | 19 +++++++++++++++++++
 testsuite/tests/typecheck/should_fail/T13487.stderr |  5 +++++
 testsuite/tests/typecheck/should_fail/all.T         |  1 +
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs
index 2ec11e8..ec33bc0 100644
--- a/compiler/typecheck/TcErrors.hs
+++ b/compiler/typecheck/TcErrors.hs
@@ -611,7 +611,8 @@ mkHoleReporter ctxt
 mkUserTypeErrorReporter :: Reporter
 mkUserTypeErrorReporter ctxt
   = mapM_ $ \ct -> do { err <- mkUserTypeError ctxt ct
-                      ; maybeReportError ctxt err }
+                      ; maybeReportError ctxt err
+                      ; addDeferredBinding ctxt err ct }
 
 mkUserTypeError :: ReportErrCtxt -> Ct -> TcM ErrMsg
 mkUserTypeError ctxt ct = mkErrorMsgFromCt ctxt ct
diff --git a/testsuite/tests/typecheck/should_fail/T13487.hs b/testsuite/tests/typecheck/should_fail/T13487.hs
new file mode 100644
index 0000000..6b5462e
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T13487.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -fdefer-type-errors #-}
+
+module T13487 where
+
+import Data.Kind (Constraint)
+import GHC.TypeLits
+
+data Foo a b where
+  K :: Error a b => a -> b -> Foo a b
+
+type family Error a b :: Constraint where
+  Error Int Int = ()
+  Error _   _   = TypeError ('Text "GHC panic in 3... 2... 1...")
+
+foo = K 'a' 'b'
diff --git a/testsuite/tests/typecheck/should_fail/T13487.stderr b/testsuite/tests/typecheck/should_fail/T13487.stderr
new file mode 100644
index 0000000..c6f6c26
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T13487.stderr
@@ -0,0 +1,5 @@
+
+T13487.hs:19:7: warning: [-Wdeferred-type-errors (in -Wdefault)]
+    • GHC panic in 3... 2... 1...
+    • In the expression: K 'a' 'b'
+      In an equation for ‘foo’: foo = K 'a' 'b'
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 41c379e..fe69ce0 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -427,6 +427,7 @@ test('StrictBinds', normal, compile_fail, [''])
 test('T13068', [extra_files(['T13068.hs', 'T13068a.hs', 'T13068.hs-boot', 'T13068m.hs'])], multimod_compile_fail, ['T13068m', ''])
 test('T13105', normal, compile_fail, [''])
 test('LevPolyBounded', normal, compile_fail, [''])
+test('T13487', normal, compile, [''])
 test('T13292', normal, multimod_compile, ['T13292', '-v0 -fdefer-type-errors'])
 test('T13300', normal, compile_fail, [''])
 test('T12709', normal, compile_fail, [''])



More information about the ghc-commits mailing list