diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-11-05 11:28:53 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-12-18 05:50:33 -0500 |
commit | 7a93435b991513b71174c807b4e99ad90f4e5058 (patch) | |
tree | b73379e691967b81a751462b2b051a91ab0ee2ed /utils | |
parent | 659fcb14937e60510e3eea4c1211ea117419905b (diff) | |
download | haskell-7a93435b991513b71174c807b4e99ad90f4e5058.tar.gz |
Use HsOuterExplicit in instance sigs in deriving-generated code
Issue #18914 revealed that `GeneralizedNewtypeDeriving` would generate code
that mentions unbound type variables, which is dangerously fragile. The
problem (and fix) is described in the new `Wrinkle: Use HsOuterExplicit`
in `Note [GND and QuantifiedConstraints]`. The gist of it: make sure to
put the top-level `forall`s in `deriving`-generated instance signatures in an
`HsOuterExplicit` to ensure that they scope over the bodies of methods
correctly. A side effect of this process is that it will expand any type
synonyms in the instance signature, which will surface any `forall`s that
are hidden underneath type synonyms (such as in the test case for #18914).
While I was in town, I also performed some maintenance on `NewHsTypeX`, which
powers `GeneralizedNewtypeDeriving`:
* I renamed `NewHsTypeX` to `HsCoreTy`, which more accurately describes its
intended purpose (#15706). I also made `HsCoreTy` a type synonym instead of
a newtype, as making it a distinct data type wasn't buying us much.
* To make sure that mistakes similar to #18914 do not occur later, I added an
additional validity check when renaming `HsCoreTy`s that complains if an
`HsCoreTy`s contains an out-of-scope type variable. See the new
`Note [Renaming HsCoreTys]` in `GHC.Rename.HsType` for the details.
Fixes #15706. Fixes #18914. Bumps the `haddock` submodule.
Diffstat (limited to 'utils')
m--------- | utils/haddock | 0 |
1 files changed, 0 insertions, 0 deletions
diff --git a/utils/haddock b/utils/haddock -Subproject 059acb11d6134ee0d896bcf73c870958557a390 +Subproject c3b276d94e207717731512d1e1f8b59b729b653 |