[Git][ghc/ghc][wip/T23496-take-three] 2 commits: Split GHC.Generics into two modules
Ryan Scott (@RyanGlScott)
gitlab at gitlab.haskell.org
Sat Jul 15 00:45:33 UTC 2023
Ryan Scott pushed to branch wip/T23496-take-three at Glasgow Haskell Compiler / GHC
Commits:
6c2d8476 by Ryan Scott at 2023-07-14T20:44:11-04:00
Split GHC.Generics into two modules
Most of `GHC.Generics` has now been moved to `GHC.Generics.Internal`, which
`GHC.Generics` re-exports. The only things now defined in `GHC.Generics` are
the derived `Generic(1)` instances. These need to be put in a different module
because of GHC's new approach to dependency analysis used in a fix for #23496
(to be done in a subsequent commit), which is perfectly within its rights to
typecheck a generated `Rep` instance before it typechecks any of the
definitions that are referenced in the right-hand side of the instance.
Putting the definitions in a separate module from the derived `Generic`
instances (and therefore the generated `Rep` instances) is a sure-fire way to
ensure that this doesn't happen.
This causes a fair bit of churn in the expected output of test cases in the
test suite, but all of the changes are simply from switching to displaying
"`GHC.Generics.Internal`" instead of "`GHC.Generics`".
- - - - -
6e18f0d0 by Ryan Scott at 2023-07-14T20:44:20-04:00
deriving: Typecheck associated family instances before instance bindings
This is a significant overhaul of the way that `deriving` clauses and
standalone `deriving` declarations are typechecked. The highlights:
* Standalone `deriving` declarations are located in the new `DerivInstD`
constructor of `ClsInstDecl`, rather than as part of the `DerivD` constructor
of `HsGroup`. This move now means that standalone `deriving` instance
declarations are located alongside other forms of instance declarations,
which makes it easier to perform SCC analysis on them, as they are now part
of a `TyClGroup`.
* Now that everything `deriving`-related lives in `TyClGroup`s, we now
typecheck all of the associated type family instances that are generated from
`deriving` clauses/declarations first (in `tcTyClGroup`) _before_
typechecking any of the generated instance bindings, which happen after all
of the `TyClGroup`s have been processed. Doing so is essential to ensuring
that these associated type instances are in scope when needed to typecheck
other code in later `TyClGroup`s, such as the failing examples seen
in #23496. I have written an extensive `Note [Staging of deriving]` (previously
`Note [Staging of tcDeriving]`) to describe how everything works.
The second bullet point above involves quite a bit of churn in the expected
output of several test cases. This is for two reasons:
1. The order in which things are printed with `-ddump-deriv` is now different,
since `deriving`-related family instances are now generated earlier in the
typechecker.
2. If a test case errors out when typechecking a `deriving`-related family
instance, then GHC will stop there before printing any errors involving the
generated instance bindings. (Previously, both sorts of errors were printed
simultaneously.) As such, some expected-to-fail test cases do not print out
as many errors as before.
Fixes #23496.
- - - - -
22 changed files:
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Stats.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/Instance.hs-boot
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/ThToHs.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- libraries/base/GHC/Generics.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c955449e244a027fc12f86c387dac6be773aa27f...6e18f0d0e43238cc41bd3146c3d55b5b6c32033f
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c955449e244a027fc12f86c387dac6be773aa27f...6e18f0d0e43238cc41bd3146c3d55b5b6c32033f
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230714/12a49939/attachment.html>
More information about the ghc-commits
mailing list