[GHC] #13738: TypeApplications-related GHC internal error

GHC ghc-devs at haskell.org
Tue Aug 29 08:37:24 UTC 2017


#13738: TypeApplications-related GHC internal error
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  simonpj
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
                                     |  TypeApplications
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #13985            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Simon Peyton Jones <simonpj@…>):

 In [changeset:"0257dacf228024d0cc6ba247c707130637a25580/ghc"
 0257dacf/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="0257dacf228024d0cc6ba247c707130637a25580"
 Refactor bindHsQTyVars and friends

 This work was triggered by Trac #13738, which revealed to me that
 the code RnTypes.bindHsQTyVars and bindLHsTyVarBndrs was a huge
 tangled mess -- and outright wrong on occasion as the ticket showed.

 The big problem was that bindLHsTyVarBndrs (which is invoked at every
 HsForAll, including nested higher rank ones) was attempting to bind
 implicit kind variables, which it has absolutely no busineess doing.
 Imlicit kind quantification is done at the outside only, in fact
 precisely where we have HsImplicitBndrs or LHsQTyVars (which also
 has implicit binders).

 Achieving this move was surprisingly hard, because more and more
 barnacles had accreted aroud the original mistake.  It's much
 much better now.

 Summary of changes.  Almost all the action is in RnTypes.

 * Implicit kind variables are bound only by
   - By bindHsQTyVars, which deals with LHsQTyVars
   - By rnImplicitBndrs, which deals with HsImplicitBndrs

 * bindLHsTyVarBndrs, and bindLHsTyVarBndr are radically simplified.
   They simply does far less, and have lots their forest of
   incomprehensible accumulating parameters.  (To be fair, some of
   the code in bindLHsTyVarBndrs just moved to bindHsQTyVars, but
   in much more perspicuous form.)

 * The code that checks if a variable appears in both a kind and
   a type (triggering RnTypes.mixedVarsErr) was bizarre.  E.g.
   we had this in RnTypes.extract_hs_tv_bndrs
        ; check_for_mixed_vars bndr_kvs acc_tvs
        ; check_for_mixed_vars bndr_kvs body_tvs
        ; check_for_mixed_vars body_tvs acc_kvs
        ; check_for_mixed_vars body_kvs acc_tvs
        ; check_for_mixed_vars locals body_kvs
   I cleaned all this up; now we check for mixed use at binding
   sites only.

 * Checks for "Variable used as a kind before being bound", like
      data T (a :: k) k = rhs
   now just show up straightforwardly as "k is not in scope".
   See Note [Kind variable ordering]

 * There are some knock-on simplifications in RnSource.
 }}}

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


More information about the ghc-tickets mailing list