Add a missing zonk in TcDerivInfer.simplifyDeriv
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 11 Oct 2017 15:17:41 +0000 (16:17 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 11 Oct 2017 15:17:41 +0000 (16:17 +0100)
I'm astonished that anything worked without this!

Fixes Trac #14339

compiler/typecheck/TcDerivInfer.hs
testsuite/tests/deriving/should_compile/T14339.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T

index f598e70..9095977 100644 (file)
@@ -676,6 +676,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 (file)
index 0000000..e2521f2
--- /dev/null
@@ -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
index 65c6d72..82cee03 100644 (file)
@@ -96,3 +96,4 @@ test('T13919', normal, compile, [''])
 test('T13998', normal, compile, [''])
 test('T14045b', normal, compile, [''])
 test('T14094', normal, compile, [''])
+test('T14339', normal, compile, [''])