[GHC] #13371: instance selection too eager

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I see a regression in 8.0.2: the `g_f'` definition is rejected. The error goes away if I do one of: * -XNoMonoLocalBinds * -XNoPolyKinds * pasting the inferred type of `g_f` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by aavogt): * Attachment "too_eager.hs" added. minimal test case coming from Data.HList.Dredge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: 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 rwbarton): No error in 8.0.1, though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager
-------------------------------------+-------------------------------------
Reporter: aavogt | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.2
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):
* cc: niteria (added)
Comment:
I tried to figure out where in the 8.0.2 branch this regression was
introduced. Unfortunately, I wasn't able to isolate an exact commit,
because the range of commits in which it was introduced doesn't build.
However, I know for sure it was introduced between:
* cc02156b859159eff7d86043f67826c17f2bd170 (where the bug is not present):
{{{
From cc02156b859159eff7d86043f67826c17f2bd170 Mon Sep 17 00:00:00 2001
From: Bartosz Nitka

#13371: instance selection too eager
-------------------------------------+-------------------------------------
Reporter: aavogt | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.2
checker) |
Resolution: | Keywords:
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 RyanGlScott):
Actually, compiling these commits from the HEAD branch (instead of the
8.0.2 branch) turned out to be more fruitful. I discovered that the commit
which introduced this regression is
c9bcaf3165586ac214fa694e61c55eb45eb131ab:
{{{
From c9bcaf3165586ac214fa694e61c55eb45eb131ab Mon Sep 17 00:00:00 2001
From: Bartosz Nitka

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: 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 niteria): This reproduces on recent HEAD. This appears to be another case of unspoken assumptions about the order. On top of c9bcaf3165586ac214fa694e61c55eb45eb131ab it suffices to make this change: {{{ --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -874,7 +874,7 @@ quantifyZonkedTyVars gbl_tvs (DV{ dv_kvs = dep_tkvs, dv_tvs = nondep_tkvs }) -- closeOverKinds all_cvs: do not quantify over coercion -- variables, or any any tvs that a covar depends on - nondep_tvs = dVarSetElems $ + nondep_tvs = varSetElems . dVarSetToVarSet $ nondep_tkvs `dVarSetMinusVarSet` gbl_tvs -- No worry about dependent covars here; they are -- all in dep_tkvs }}} to make the problem go away. It also fixes the problem on HEAD, except you have to use `nonDetEltsUFM` instead of `varSetElems`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: 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 niteria): Broken GHC infers: {{{ g_f :: forall (b :: k0) k c a. F a (Proxy b) => a -> c }}} , while the working one infers {{{ g_f :: forall k (b :: k) c a. F a (Proxy b) => a -> c }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by niteria): * cc: goldfire (added) Comment: I think this has been broken since 6746549772c5cc0ac66c0fce562f297f4d4b80a2. Running before c9bcaf3165586ac214fa694e61c55eb45eb131ab with `-dunique- increment=-1` reproduces the problem. It appears that when we `growThetaTyVarsDSet` we add some kind variables to the nondependent type var set, but the vars inside depend on the newly added kind var. We then linearize without any regard for dependencies, because there shouldn't be any. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * priority: normal => high * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager
-------------------------------------+-------------------------------------
Reporter: aavogt | Owner: (none)
Type: bug | Status: new
Priority: high | Milestone: 8.2.1
Component: Compiler (Type | Version: 8.0.2
checker) |
Resolution: | Keywords:
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 Simon Peyton Jones

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | polykinds/T13371 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => polykinds/T13371 * resolution: => fixed Comment: This is a bit of a big commit, but I think it'd be worth doing for 8.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | polykinds/T13371 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): See also #13393 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13371: instance selection too eager -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | polykinds/T13371 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): This was merged in a920404fb12fb52a59e4f728cce4d662a418c5f8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13371#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC