Clean up the inferred type variable restriction
This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect.
parent
502de556
Branches wip/ttg-booleanformula
No related tags found
Pipeline #22812 passed with warnings
Stage: lint
Stage: quick-build
Stage: build
Stage: full-build
Stage: cleanup
Stage: packaging
Stage: testing
Stage: deploy
Showing
- compiler/GHC/Hs/Type.hs 6 additions, 0 deletionscompiler/GHC/Hs/Type.hs
- compiler/GHC/Rename/Bind.hs 15 additions, 9 deletionscompiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Expr.hs 1 addition, 1 deletioncompiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs 10 additions, 39 deletionscompiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs 40 additions, 76 deletionscompiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Pat.hs 1 addition, 1 deletioncompiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Utils.hs 135 additions, 1 deletioncompiler/GHC/Rename/Utils.hs
- testsuite/tests/quantified-constraints/T18432.hs 10 additions, 0 deletionstestsuite/tests/quantified-constraints/T18432.hs
- testsuite/tests/quantified-constraints/all.T 1 addition, 0 deletionstestsuite/tests/quantified-constraints/all.T
- testsuite/tests/typecheck/should_compile/ExplicitSpecificity4.hs 0 additions, 0 deletions...te/tests/typecheck/should_compile/ExplicitSpecificity4.hs
- testsuite/tests/typecheck/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_fail/T18455.hs 7 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T18455.hs
- testsuite/tests/typecheck/should_fail/T18455.stderr 4 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T18455.stderr
- testsuite/tests/typecheck/should_fail/all.T 1 addition, 1 deletiontestsuite/tests/typecheck/should_fail/all.T
Loading
-
mentioned in merge request !3707 (closed)
-
mentioned in issue #18432 (closed)
-
mentioned in issue #18455 (closed)
Please register or sign in to comment