Oh, you are right. I was thinking of generating the Typeable bindings (and record selectors) at the end of tcTyAndClassDecls. That would work perfectly EXCEPT that we only want to generate the module-name bindings once.
But it's easy to spot if it's been done already because tcg_tr_module is a Just. So, I suggest you generate Typeable binding along with record selectors, at the end of tcTyAndClassDecls; but take care that mkModIdBindings is a no-op if tcg_tr_module says it's been done already. But I don't mind if you want to leave it as-is, provided you comment to avoid the confusion I fell into. Simon | -----Original Message----- | From: Ben Gamari [mailto:[email protected]] | Sent: 17 April 2016 10:44 | To: Simon Peyton Jones <[email protected]> | Cc: GHC developers <[email protected]> | Subject: RE: [GHC] #11824: GHC error in desugarer lookup | | Simon Peyton Jones <[email protected]> writes: | | > | The problem is this: we must generate and typecheck record | selectors | > | on a per-group basis, since they may be used by later groups. | > | > Why? Record selectors are value bindings which aren't used when | typechecking data types. | > | Yes, they are value bindings and may be used in bindings in later | groups. For instance, let's consider the following, | | data ARecord = ARecord { aField :: Int } | | $(return []) -- group delimiter | | aFieldIncr :: ARecord -> Int | aFieldIncr = succ . aField | | My point in, | | > | we must generate and typecheck record selectors on a per-group | basis | | is that we must generate the `aField` binding before proceeding to | typecheck the second group (containing `aFieldIncr`). Failing to do | this would result in `aField` being out of scope when we attempted to | typecheck the RHS of `aFieldIncr`. Perhaps I have misunderstood? | | Cheers, | | - Ben _______________________________________________ ghc-devs mailing list [email protected] http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
