Refactor (again) the treatment of record-selector bindings
We were generating them from the tcg_tcs field of the TcGblEnv, but that goes badly wrong when there are top-level Template Haskell splices, because the tcg_tcs field grows successively. If we generate record-selector binds for all the TyCons in the accumulated list, we generate them multiple times for TyCons earlier in the program. This what was happening in Trac #5665: data T = T { x :: Int } $(f 4) -- Top level splice ..more code.. Here the record selector bindings for T were being generated twice. Better instead to generate the record-selector bindings in TcTyClsDecls, right where the new TyCons are being declared (as indeed they were some time ago). This pushed me into doing some refactoring: instead of returning the record bindings, tcTyAndClassDecls adds them to the tcg_binds field of the TcGblEnv. I think the result is a bit nicer, and it has the additional merit of working.
Showing
- compiler/typecheck/TcBinds.lhs 40 additions, 26 deletionscompiler/typecheck/TcBinds.lhs
- compiler/typecheck/TcDeriv.lhs 1 addition, 1 deletioncompiler/typecheck/TcDeriv.lhs
- compiler/typecheck/TcInstDcls.lhs 11 additions, 9 deletionscompiler/typecheck/TcInstDcls.lhs
- compiler/typecheck/TcRnDriver.lhs 9 additions, 27 deletionscompiler/typecheck/TcRnDriver.lhs
- compiler/typecheck/TcRnMonad.lhs 10 additions, 5 deletionscompiler/typecheck/TcRnMonad.lhs
- compiler/typecheck/TcTyClsDecls.lhs 20 additions, 14 deletionscompiler/typecheck/TcTyClsDecls.lhs
Loading
Please register or sign in to comment