[GHC] #15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar"

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Keywords: | Operating System: Unknown/Multiple QuantifiedConstraints | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I wanted to see if we're ready to put `join` into `Monad`. So I typed this in: {{{#!hs {-# LANGUAGE QuantifiedConstraints, StandaloneDeriving, GeneralizedNewtypeDeriving #-} module Bug where import Prelude hiding ( Monad(..) ) import Data.Coerce ( Coercible ) class Monad m where (>>=) :: m a -> (a -> m b) -> m b join :: m (m a) -> m a newtype StateT s m a = StateT { runStateT :: s -> m (s, a) } instance Monad m => Monad (StateT s m) where ma >>= fmb = StateT $ \s -> runStateT ma s >>= \(s1, a) -> runStateT (fmb a) s1 join ssa = StateT $ \s -> runStateT ssa s >>= \(s, sa) -> runStateT sa s newtype IntStateT m a = IntStateT { runIntStateT :: StateT Int m a } deriving instance (Monad m, forall p q. Coercible p q => Coercible (m p) (m q)) => Monad (IntStateT m) }}} This looks like it should be accepted. But I get {{{ ghc-stage2: panic! (the 'impossible' happened) (GHC version 8.5.20180617 for x86_64-apple-darwin): addTcEvBind NoEvBindsVar [G] df_a67k = \ (@ p_a62C) (@ q_a62D) (v_B1 :: Coercible p_a62C q_a62D) -> coercible_sel @ * @ (m_a64Z[ssk:1] p_a62C) @ (m_a64Z[ssk:1] q_a62D) (df_a651 @ p_a62C @ q_a62D v_B1) a67c Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable pprPanic, called at compiler/typecheck/TcRnMonad.hs:1404:5 in ghc:TcRnMonad }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Simpler test case: {{{#!hs {-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving, QuantifiedConstraints #-} module Bug where import Data.Coerce class C m where join :: m (m a) -> m a newtype T m a = MkT (m a) deriving instance (C m, forall p q. Coercible p q => Coercible (m p) (m q)) => C (T m) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): This is blocking #9123. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * blocking: => 9123 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Good grief. At first I thought the problem was simple, but now I realise there is more to it than that. Here is a minimised version that crashes {{{ {-# LANGUAGE TypeApplications, ImpredicativeTypes, ScopedTypeVariables, QuantifiedConstraints, StandaloneDeriving, GeneralizedNewtypeDeriving #-} module T15290 where import Prelude hiding ( Monad(..) ) import Data.Coerce ( Coercible, coerce ) class Monad m where join :: m (m a) -> m a newtype StateT s m a = StateT { runStateT :: s -> m (s, a) } newtype IntStateT m a = IntStateT { runIntStateT :: StateT Int m a } instance (Monad m, forall p q. Coercible p q => Coercible (m p) (m q)) => Monad (IntStateT m) where join = coerce @(forall a. StateT Int m (StateT Int m a) -> StateT Int m a) @(forall a. IntStateT m (IntStateT m a) -> IntStateT m a) join }}} The `deriving` mechanism tries to instantiate `coerce` at a polymorphic type, a form of impredicative polymorphism, so it's on thin ice. And in fact the ice breaks. The call to `coerce` gives rise to {{{ Coercible (forall a. blah1) (forall a. blah2) }}} and that soon simplifies to the implication constraint (because of the forall) {{{ forall a <no-ev>. m (Int, IntStateT m a) ~R# m (Int, StateT Int m a) }}} But, becuase this constraint is under a forall, inside a type, we have to prove it ''without computing any term evidence''. Hence the `<no-ev>`, meaning I can't generate any term-level evidence bindings. Alas, I ''must'' generate a term-level evidence binding, to instantiate the quantified constraint. Currently GHC crashes, but I suppose it should instead decline to consult given quantified constraints if it's in a context where evidence bindings are not allowed. I don't see any way out here. All this arises from a sneaky attempt to use impredicative polymorphism. Maybe instead the derviing mechansim should generate {{{ join = (coerce @(StateT Int m (StateT Int m a) -> StateT Int m a) @(IntStateT m (IntStateT m a) -> IntStateT m a) join) :: forall a. IntStateT m (IntStateT m a) -> IntStateT m a }}} and use ordinary predicative instantiation for `coerce`. And indeed that works fine right now. It'll mean a bit more work for the `deriving` mechanism, but not much. Richard and Ryan may want to comment. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I don't think your workaround is sufficient to avoid the issue. Consider what would happen if we had a variant of `join` with this type signature: {{{#!hs join :: (forall b. b -> a) -> m (m a) -> m a }}} If we plug that in to our proposed scheme: {{{#!hs {-# LANGUAGE TypeApplications, ImpredicativeTypes, ScopedTypeVariables, QuantifiedConstraints, StandaloneDeriving, GeneralizedNewtypeDeriving #-} module T15290 where import Prelude hiding ( Monad(..) ) import Data.Coerce ( Coercible, coerce ) class Monad m where join :: (forall b. b -> a) -> m (m a) -> m a newtype StateT s m a = StateT { runStateT :: s -> m (s, a) } instance Monad m => Monad (StateT s m) where newtype IntStateT m a = IntStateT { runIntStateT :: StateT Int m a } instance (Monad m, forall p q. Coercible p q => Coercible (m p) (m q)) => Monad (IntStateT m) where join = coerce @((forall b. b -> a) -> StateT Int m (StateT Int m a) -> StateT Int m a) @((forall b. b -> a) -> IntStateT m (IntStateT m a) -> IntStateT m a) join :: forall a. (forall b. b -> a) -> IntStateT m (IntStateT m a) -> IntStateT m a }}} Then that, too, will panic: {{{ $ /opt/ghc/head/bin/ghc Bug.hs [1 of 1] Compiling T15290 ( Bug.hs, Bug.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.5.20180616 for x86_64-unknown-linux): addTcEvBind NoEvBindsVar [G] df_a1pg = \ (@ p_aW5) (@ q_aW6) (v_B1 :: Coercible p_aW5 q_aW6) -> coercible_sel @ * @ (m_a1nx[ssk:1] p_aW5) @ (m_a1nx[ssk:1] q_aW6) (df_a1nz @ p_aW5 @ q_aW6 v_B1) a1og Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable pprPanic, called at compiler/typecheck/TcRnMonad.hs:1404:5 in ghc:TcRnMonad }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Yes, I agree. I'll stop the panic (by refraining from using quantified constraints if I have no place to put the evidence) but that will make GHC reject `deriving` for * A higher rank method * That makes essential use of a quantified constraint * Under a forall I don't see how to avoid that restriction. If anyone else does, please say so! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Wait, you're saying that deriving classes with methods that use higher- rank types will no longer work? If so, that is going to break enormous swaths of code both in the wild and in the test suite (see [http://git.haskell.org/ghc.git/blob/3048a87a3f2ef97d9f6559064d7a32ec7566542b... here] for one example). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Wait, you're saying that deriving classes with methods that use higher- rank types will no longer work?
No, I am not saying that (see the second bullet). It's just that if you can't ''simultaneously'' exploit impredicative instantiation of `coerce` and quantified constraints. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Ah, my apologies. I interpreted that list of bullet points as three separate criteria under which `deriving` would fail, not as a list of three conditions which must simultaneously hold. In that case, I feel much better about this idea (if this really is the only way forward). I've always thought that derived instance methods should use `InstanceSigs`, and this gives us a good excuse to do so. (And I think certain folks, possibly from Iceland, will find that more aesthetically pleasing to look at in `-ddump-deriv` output.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): You could use `InstanceSigs`; or just an expression type signature as I have done. And incidentally you can them omit the second type argument to `coerce`, which is perhaps nice. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): To be clear: are you working on the change to `deriving` alongside the typechecker changes? Or should I implement the `deriving` bits? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Could you do the `deriving` bits? Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): See also #14883, which is very similar -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Hm, I've hit a roadblock when trying to switch over to the scheme proposed in comment:5. Consider this code: {{{#!hs {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ImpredicativeTypes #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -ddump-deriv #-} module Bug where import Data.Coerce class C a where c :: Int -> forall b. b -> a instance C Int where c _ _ = 42 newtype Age = MkAge Int -- This is what -- -- deriving instance C Age -- -- would generate: instance C Age where c = coerce @( Int -> forall b. b -> a) c :: forall a. Int -> forall b. b -> a }}} This fails to typecheck: {{{ $ /opt/ghc/8.4.3/bin/ghc Bug.hs [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) Bug.hs:26:7: error: • Couldn't match representation of type ‘forall b2. b2 -> a’ with that of ‘b1 -> a’ arising from a use of ‘coerce’ • In the expression: coerce @(Int -> forall b. b -> a) c :: forall a. Int -> forall b. b -> a In an equation for ‘c’: c = coerce @(Int -> forall b. b -> a) c :: forall a. Int -> forall b. b -> a In the instance declaration for ‘C Age’ | 26 | c = coerce @( Int -> forall b. b -> a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... }}} The same error occurs if I use `InstanceSigs`. Any ideas on how to make this work? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): The current behavior was introduced in b612da667fe8fa5277fc78e972a86d4b35f98364 That commit fixes some impredicativity bug but also rewrites GND to use type application. However, the change to GND also has it work with polytypes instead of its previous behavior, using monotypes. It sounds like we want to go to the previous behavior. As for Ryan's question: try passing both type arguments to `coerce`. As explained in the visible type application paper, type signatures on expressions are ''deeply skolemized'', which is causing havoc for you here. I think including the second type parameter to `coerce` will solve the problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Thanks Richard, that did indeed solve that problem. On the other hand, I seem to have hit an even trickier problem. For context: this is the entirety of my patch at the moment: {{{#!diff diff --git a/compiler/typecheck/TcGenDeriv.hs b/compiler/typecheck/TcGenDeriv.hs index b944520..1f1cba2 100644 --- a/compiler/typecheck/TcGenDeriv.hs +++ b/compiler/typecheck/TcGenDeriv.hs @@ -1668,13 +1668,16 @@ gen_Newtype_binds loc cls inst_tvs inst_tys rhs_ty [] rhs_expr] where Pair from_ty to_ty = mkCoerceClassMethEqn cls inst_tvs inst_tys rhs_ty meth_id + (_, _, from_tau) = tcSplitSigmaTy from_ty + (_, _, to_tau) = tcSplitSigmaTy to_ty meth_RDR = getRdrName meth_id rhs_expr = nlHsVar (getRdrName coerceId) - `nlHsAppType` from_ty - `nlHsAppType` to_ty - `nlHsApp` nlHsVar meth_RDR + `nlHsAppType` from_tau + `nlHsAppType` to_tau + `nlHsApp` nlHsVar meth_RDR + `nlExprWithTySig` to_ty mk_atf_inst :: TyCon -> TcM FamInst mk_atf_inst fam_tc = do }}} i.e., drop the `forall`s from each of the types inside the explicit type applications, and put an explicit type signature (with `forall`s) on the whole expression. Now here's the kicker: if you try that patch on this program: {{{#!hs {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -ddump-deriv #-} module Bug where import Data.Coerce class Foo a where bar :: a -> Maybe b instance Foo Int where bar _ = Nothing newtype Age = MkAge Int deriving Foo }}} Then it no longer typechecks: {{{ $ inplace/bin/ghc-stage2 --interactive ../Bug2.hs GHCi, version 8.7.20180621: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( ../Bug2.hs, interpreted ) ==================== Derived instances ==================== Derived class instances: instance Bug.Foo Bug.Age where Bug.bar = GHC.Prim.coerce @(GHC.Types.Int -> GHC.Maybe.Maybe b_a1AR) @(Bug.Age -> GHC.Maybe.Maybe b_a1AR) Bug.bar :: forall (b_a1AR :: TYPE GHC.Types.LiftedRep). Bug.Age -> GHC.Maybe.Maybe b_a1AR Derived type family instances: ../Bug2.hs:16:12: error: • Couldn't match type ‘b1’ with ‘b’ ‘b1’ is a rigid type variable bound by an expression type signature: forall b1. Age -> Maybe b1 at ../Bug2.hs:16:12-14 ‘b’ is a rigid type variable bound by the type signature for: bar :: forall b. Age -> Maybe b at ../Bug2.hs:16:12-14 Expected type: Age -> Maybe b1 Actual type: Age -> Maybe b • In the expression: coerce @(Int -> Maybe b) @(Age -> Maybe b) bar :: forall (b :: TYPE GHC.Types.LiftedRep). Age -> Maybe b In an equation for ‘bar’: bar = coerce @(Int -> Maybe b) @(Age -> Maybe b) bar :: forall (b :: TYPE GHC.Types.LiftedRep). Age -> Maybe b When typechecking the code for ‘bar’ in a derived instance for ‘Foo Age’: To see the code I am typechecking, use -ddump-deriv In the instance declaration for ‘Foo Age’ • Relevant bindings include bar :: Age -> Maybe b (bound at ../Bug2.hs:16:12) | 16 | deriving Foo | ^^^ }}} For the life of me, I can't figure out why this shouldn't typecheck. What's even stranger, if I take the code that GHC's giving me and paste it back into the source: {{{#!hs {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -ddump-deriv #-} module Bug where import Data.Coerce class Foo a where bar :: a -> Maybe b instance Foo Int where bar _ = Nothing newtype Age = MkAge Int -- deriving Foo instance Foo Age where bar = coerce @(Int -> Maybe b) @(Age -> Maybe b) bar :: forall b. Age -> Maybe b }}} Then it typechecks again! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar"
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
| QuantifiedConstraints
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking: 9123, 14883
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => quantified-constraints/T15290, T15290a -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): To make things more outrageous, if I manually freshen the type variable binders in `to_ty` in comment:17 (using `freshTyVarBndrs`), //then// it works. Quite mysterious. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I'm on it. Digging through manure in `TcHsType`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): On the subject of the actual panic observed in this ticket, I don't think Simon's commit quite fixed it. I'm still observing the panic on commit 122ba98af22c2b016561433dfa55bbabba98d972 with this program (taken from #14883): {{{#!hs {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ImpredicativeTypes #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module Bug where import Data.Coerce import Data.Kind type Representational1 m = (forall a b. Coercible a b => Coercible (m a) (m b) :: Constraint) class Representational1 f => Functor' f where fmap' :: (a -> b) -> f a -> f b class Functor' f => Applicative' f where pure' :: a -> f a (<*>@) :: f (a -> b) -> f a -> f b class Functor' t => Traversable' t where traverse' :: Applicative' f => (a -> f b) -> t a -> f (t b) -- Typechecks newtype T1 m a = MkT1 (m a) deriving (Functor', Traversable') }}} {{{ $ ghc/inplace/bin/ghc-stage2 Bug.hs [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 8.7.20180621 for x86_64-unknown-linux): addTcEvBind NoEvBindsVar [G] df_a1bF = \ (@ a_asM) (@ b_asN) (v_B1 :: Coercible a_asM b_asN) -> coercible_sel @ * @ (m_a1bn[sk:1] a_asM) @ (m_a1bn[sk:1] b_asN) (df_a1bE @ a_asM @ b_asN v_B1) a1bw Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable pprPanic, called at compiler/typecheck/TcRnMonad.hs:1404:5 in ghc:TcRnMonad }}} The panic does not occur if I derive `Traversable'` through `StandaloneDeriving`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Replying to [comment:21 simonpj]:
I'm on it. Digging through manure in `TcHsType`.
Presumably mine. What's up this time? :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:23 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Good grief -- again! comment:17 is ghastly. Here's what is happening. What we are 'really' checking is {{{ bar = ((coerce @(Int -> Maybe b) @(Age -> Maybe b) bar) :: forall b. Age -> Maybe b) :: forall b. Age -> Maybe b }}} where * the outer type signature comes from checking that the type of the method matches the type that the class expects * the inner one comes from the 'deriving' patch Because both of those type sigs ultimately from the same source, both 'b's happen to have the same unique. That should be fine but it isn't: * The outer forall adds `b :-> b1[sk]` to the type environment. That's fine, even though this outer forall b does not scope; the type envt isn't responsible for resolving lexical scoping. * The `forall` on the inner signature is typechecked with by the `HsForAllTy` case of `tc_hs_type`, which calls * `tcExplicitTKBndrs`, which calls * `tcHsTyVarBndr`, which calls * `tcHsTyVarName`, '''which has a special case for type variables already in scope''' * The in-scope handling in `tcHsTyVarName` is a very special case intended '''only''' for the binders in the `LHSQTyVars` of an associated type or type instance declaration, nested inside a class decl. Yet it is here being used (accidentally) for the `forall` of a type signature, a situation that it is utterly unsuitable for. Even if the tyvar for a `forall` is already in scope, that should be utterly irrelevant to the type signature. * The net result is chaos: we end up with two different skolems that really represent the same type variable. Conclusion: we should radically narrow the cases in which this funny in-scope test applies. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:24 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar"
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
| QuantifiedConstraints
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: quantified-
| constraints/T15290, T15290a
Blocked By: | Blocking: 9123, 14883
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
Simon made a commit (9fc40c733ba8822a04bd92883801b214dee099ca) addressing
the issue in comment:24, but he accidentally tagged the wrong ticket
number. Here is the commit:
{{{
From 9fc40c733ba8822a04bd92883801b214dee099ca Mon Sep 17 00:00:00 2001
From: Simon Peyton Jones

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Thanks for putting this in the right place. I think your patch should work now; and I tried this which seems even better {{{ diff --git a/compiler/typecheck/TcGenDeriv.hs b/compiler/typecheck/TcGenDeriv.hs index b944520..736eb14 100644 --- a/compiler/typecheck/TcGenDeriv.hs +++ b/compiler/typecheck/TcGenDeriv.hs @@ -1668,13 +1668,12 @@ gen_Newtype_binds loc cls inst_tvs inst_tys rhs_ty [] rhs_expr] where Pair from_ty to_ty = mkCoerceClassMethEqn cls inst_tvs inst_tys rhs_ty meth_id - meth_RDR = getRdrName meth_id + (_, _, from_tau) = tcSplitSigmaTy from_ty rhs_expr = nlHsVar (getRdrName coerceId) - `nlHsAppType` from_ty - `nlHsAppType` to_ty - `nlHsApp` nlHsVar meth_RDR + `nlHsApp` (nlHsVar meth_RDR `nlExprWithTySig` from_tau) + `nlExprWithTySig` to_ty mk_atf_inst :: TyCon -> TcM FamInst mk_atf_inst fam_tc = do @@ -1703,11 +1702,6 @@ gen_Newtype_binds loc cls inst_tvs inst_tys rhs_ty rep_cvs' = toposortTyVars rep_cvs pp_lhs = ppr (mkTyConApp fam_tc rep_lhs_tys) -nlHsAppType :: LHsExpr GhcPs -> Type -> LHsExpr GhcPs -nlHsAppType e s = noLoc (HsAppType hs_ty e) - where - hs_ty = mkHsWildCardBndrs $ nlHsParTy (typeToLHsType s) - nlExprWithTySig :: LHsExpr GhcPs -> Type -> LHsExpr GhcPs nlExprWithTySig e s = noLoc $ ExprWithTySig hs_ty $ parenthesizeHsExpr sigPrec e }}} I like this because it feels more uniform: two type signatures rather that one type signature and two type applications. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:26 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Thanks, Simon. Do be aware that the program in comment:22 still panics. I'll check that it as an `expect_broken` test case in my upcoming patch. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:27 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

On the subject of the actual panic observed in this ticket, I don't
#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): think Simon's commit quite fixed it. I'm still observing the panic on commit 122ba98af22c2b016561433dfa55bbabba98d972 with this program (taken from #14883): Are you sure? It compiles on HEAD for me. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:28 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Actually, it turns out that the approach in comment:26 isn't feasible. It breaks on the program in comment:15, as it generates the following code: {{{#!hs {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module T15290b where import Data.Coerce class C a where c :: Int -> forall b. b -> a instance C Int where c _ _ = 42 newtype Age = MkAge Int -- deriving C instance C Age where c = coerce (c :: Int -> forall b. b -> Int) :: Int -> forall b. b -> Age }}} {{{ $ ghc Bug.hs [1 of 1] Compiling T15290b ( Bug.hs, Bug.o ) Bug.hs:19:7: error: • Couldn't match representation of type ‘b0’ with that of ‘b1’ arising from a use of ‘coerce’ ‘b1’ is a rigid type variable bound by a type expected by the context: Int -> forall b1. b1 -> Age at Bug.hs:19:50-74 • In the expression: coerce (c :: Int -> forall b. b -> Int) :: Int -> forall b. b -> Age In an equation for ‘c’: c = coerce (c :: Int -> forall b. b -> Int) :: Int -> forall b. b -> Age In the instance declaration for ‘C Age’ | 19 | c = coerce (c :: Int -> forall b. b -> Int) :: Int -> forall b. b -> Age | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ }}} Since this does typecheck with the `TypeApplications`-based approach, I'll go with that one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:29 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123, 14883 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Ah, correction, I can reproduce this. Weird. I'll look.
Gah. Yet another unrelated bug, this time in `TcDerivInfer.simplifyDeriv`. Patch coming. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:30 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123 Related Tickets: | Differential Rev(s): Phab:D4895 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D4895 * blocking: 9123, 14883 => 9123 Comment: Phab:D4895 implements the `deriving`-related bits. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:31 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar"
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
| QuantifiedConstraints
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: quantified-
| constraints/T15290, T15290a
Blocked By: | Blocking: 9123
Related Tickets: | Differential Rev(s): Phab:D4895
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
OK, this commit fixes the problem reported in comment:22, and adds the
code there as a regression test.
This is the ''third'' separate bug exposed by the original bug report.
Wow.
{{{
commit 261dd83cacec71edd551e9c581d05285c9ea3226
Author: Simon Peyton Jones

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123 Related Tickets: | Differential Rev(s): Phab:D4895 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Replying to [comment:32 simonpj]:
Are we done now?
I certainly hope so! :) I've rebased Phab:D4895 on top of your most recent changes, so that should wrap things up on this ticket. Another question remains of what to do with #9123, which requests that `GeneralizedNewtypeDeriving` emit quantified constraints involving `Coercible`. But this ticket shows that doing so often leads to disaster. In light of this, should we close #9123 as wontfix? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:33 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123 Related Tickets: | Differential Rev(s): Phab:D4895 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): As comment:63 says (on #9123) I don't think we should ever infer quantified constraints, regardless of this ticket. So I'm fine with closing #9123 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:34 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123 Related Tickets: | Differential Rev(s): Phab:D4895 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:35 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290, T15290a Blocked By: | Blocking: 9123 Related Tickets: | Differential Rev(s): Phab:D4895 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I'm putting this in merge state since there are already a few patches that need to be backported. However, the issue here isn't quite fixed until Phab:D4895 is merged to `master`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:36 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar"
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: bug | Status: merge
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
| QuantifiedConstraints
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: quantified-
| constraints/T15290, T15290a
Blocked By: | Blocking: 9123
Related Tickets: | Differential Rev(s): Phab:D4895
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290{,a,b}, | deriving/should_compile/T15290{c,d}, | deriving/should_compile/T14883 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4895 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * testcase: quantified-constraints/T15290, T15290a => quantified-constraints/T15290{,a,b}, deriving/should_compile/T15290{c,d}, deriving/should_compile/T14883 * blocking: 9123 => Comment: With the commit in comment:37, that should take care of business. As far as which commits to merge, my understanding is that you would need everything mentioned in this ticket, which encompasses: * 32eb41994f7448caf5fb6b06ed0678d79d029deb * 9fc40c733ba8822a04bd92883801b214dee099ca * 261dd83cacec71edd551e9c581d05285c9ea3226 * 132273f34e394bf7e900d0c15e01e91edd711890 Does that sound right? Also, I apologize in advance to Ben :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:38 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15290: QuantifiedConstraints: panic "addTcEvBind NoEvBindsVar" -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: quantified- | constraints/T15290{,a,b}, | deriving/should_compile/T15290{c,d}, | deriving/should_compile/T14883 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4895 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: This actually wasn't as bad as I was fearing: * 32eb41994f7448caf5fb6b06ed0678d79d029deb was merged with 61adfbe6f9926daf06031b7da2522f73addf75dc. * 9fc40c733ba8822a04bd92883801b214dee099ca was merged with 7e19610c925c45ade589b573a7e1c247cd8265ef * 261dd83cacec71edd551e9c581d05285c9ea3226 was merged with 145f7c663e6df4ecfa848c0e2e478454cf9fb1d9. * 132273f34e394bf7e900d0c15e01e91edd711890 was merged with c0323d979d3676f919d6d02aecad7a8bfdcb8b8d -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15290#comment:39 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC