diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-06-09 18:13:35 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-06-27 14:56:18 -0400 |
commit | 00418ed8459639a3843231c8b916c5fa88fdd8d2 (patch) | |
tree | 6a7f2e050d16762832e6aa535947bcfe05e95ca7 /docs/storage-mgt | |
parent | 0e83efa24636c72811e4c79fe1c7e4f7cf3170cd (diff) | |
download | haskell-00418ed8459639a3843231c8b916c5fa88fdd8d2.tar.gz |
Reject nested foralls/contexts in instance types more consistentlywip/T18240
GHC is very wishy-washy about rejecting instance declarations with
nested `forall`s or contexts that are surrounded by outermost
parentheses. This can even lead to some strange interactions with
`ScopedTypeVariables`, as demonstrated in #18240. This patch makes
GHC more consistently reject instance types with nested
`forall`s/contexts so as to prevent these strange interactions.
On the implementation side, this patch tweaks `splitLHsInstDeclTy`
and `getLHsInstDeclHead` to not look through parentheses, which can
be semantically significant. I've added a
`Note [No nested foralls or contexts in instance types]` in
`GHC.Hs.Type` to explain why. This also introduces a
`no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to
catch nested `forall`s/contexts in instance types. This function is
now used in `rnClsInstDecl` (for ordinary instance declarations) and
`rnSrcDerivDecl` (for standalone `deriving` declarations), the latter
of which fixes #18271.
On the documentation side, this adds a new
"Formal syntax for instance declaration types" section to the GHC
User's Guide that presents a BNF-style grammar for what is and isn't
allowed in instance types.
Fixes #18240. Fixes #18271.
Diffstat (limited to 'docs/storage-mgt')
0 files changed, 0 insertions, 0 deletions