[GHC] #14331: Overzealous free-floating kind check causes deriving clause to be rejected

GHC ghc-devs at haskell.org
Fri Oct 20 21:39:43 UTC 2017


#14331: Overzealous free-floating kind check causes deriving clause to be rejected
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  merge
        Priority:  normal            |            Milestone:  8.2.2
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  GHC rejects       |            Test Case:
  valid program                      |  deriving/should_compile/T14331
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 But we can only get `ty` after dropping `n` arguments.

 Relating this to the existing code in `deriveTyData`, what I've called
 `ki2` is `cls_arg_kind` and what I've called `n` is `n_args_to_drop`.
 `n_args_to_drop` is computed by counting the number of args spun off by a
 call to `splitFunTys cls_arg_kind`. For a unification variable `kappa`,
 `splitFunTys` will return no arguments -- just like it would when
 `cls_arg_kind` is `Type`. So GHC currently behaves like my algorithm; I
 just have more checks here. However, calling `splitFunTys` on a
 unification variable is bogus, because that variable could potentially
 stand for anything, including a function. This bogus use happens to work
 out, but that's more luck than science in this case, I think.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14331#comment:35>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list