[commit: ghc] ghc-8.2: Add a missing zonk in TcDerivInfer.simplifyDeriv (a05d71a)

git at git.haskell.org git at git.haskell.org
Thu Nov 9 00:42:55 UTC 2017


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

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/a05d71a73048df005c924f023607005a327e2adf/ghc

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

commit a05d71a73048df005c924f023607005a327e2adf
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Oct 11 16:17:41 2017 +0100

    Add a missing zonk in TcDerivInfer.simplifyDeriv
    
    I'm astonished that anything worked without this!
    
    Fixes Trac #14339
    
    (cherry picked from commit 13fdca3d174ff15ac347c5db78370f457a3013ee)


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

a05d71a73048df005c924f023607005a327e2adf
 compiler/typecheck/TcDerivInfer.hs                |  2 ++
 testsuite/tests/deriving/should_compile/T14339.hs | 17 +++++++++++++++++
 testsuite/tests/deriving/should_compile/all.T     |  1 +
 3 files changed, 20 insertions(+)

diff --git a/compiler/typecheck/TcDerivInfer.hs b/compiler/typecheck/TcDerivInfer.hs
index 93dcf43..bbd054c 100644
--- a/compiler/typecheck/TcDerivInfer.hs
+++ b/compiler/typecheck/TcDerivInfer.hs
@@ -622,6 +622,8 @@ simplifyDeriv pred tvs thetas
        -- Simplify the constraints
        ; solved_implics <- runTcSDeriveds $ solveWantedsAndDrop
                                           $ unionsWC wanteds
+       -- It's not yet zonked!  Obviously zonk it before peering at it
+       ; solved_implics <- zonkWC solved_implics
 
        -- See [STEP DAC HOIST]
        -- Split the resulting constraints into bad and good constraints,
diff --git a/testsuite/tests/deriving/should_compile/T14339.hs b/testsuite/tests/deriving/should_compile/T14339.hs
new file mode 100644
index 0000000..e2521f2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T14339.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE UndecidableInstances #-}
+module Bug where
+
+import GHC.TypeLits
+
+newtype Baz = Baz Foo
+  deriving Bar
+
+newtype Foo = Foo Int
+
+class Bar a where
+  bar :: a
+
+instance (TypeError (Text "Boo")) => Bar Foo where
+  bar = undefined
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index 5f94f9d..86648d3 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -89,3 +89,4 @@ test('T13272', normal, compile, [''])
 test('T13272a', normal, compile, [''])
 test('T13297', normal, compile, [''])
 test('T14331', normal, compile, [''])
+test('T14339', normal, compile, [''])



More information about the ghc-commits mailing list