Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase
Richard points out in #17688 that we use `splitLHsForAllTy` and `splitLHsSigmaTy` in places that we ought to be using the corresponding `-Invis` variants instead, identifying two bugs that are caused by this oversight: * Certain TH-quoted type signatures, such as those that appear in quoted `SPECIALISE` pragmas, silently turn visible `forall`s into invisible `forall`s. * When quoted, the type `forall a -> (a ~ a) => a` will turn into `forall a -> a` due to a bug in `DsMeta.repForall` that drops contexts that follow visible `forall`s. These are both ultimately caused by the fact that `splitLHsForAllTy` and `splitLHsSigmaTy` split apart visible `forall`s in addition to invisible ones. This patch cleans things up: * We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis` throughout the codebase. Relatedly, the `splitLHsForAllTy` and `splitLHsSigmaTy` have been removed, as they are easy to misuse. * `DsMeta.repForall` now only handles invisible `forall`s to reduce the chance for confusion with visible `forall`s, which need to be handled differently. I also renamed it from `repForall` to `repForallT` to emphasize that its distinguishing characteristic is the fact that it desugars down to `L.H.TH.Syntax.ForallT`. Fixes #17688. (cherry picked from commit 18c0d037)
Showing
- compiler/GHC/Hs/Types.hs 8 additions, 31 deletionscompiler/GHC/Hs/Types.hs
- compiler/deSugar/DsMeta.hs 20 additions, 12 deletionscompiler/deSugar/DsMeta.hs
- compiler/rename/RnSource.hs 1 addition, 1 deletioncompiler/rename/RnSource.hs
- compiler/typecheck/TcBinds.hs 1 addition, 1 deletioncompiler/typecheck/TcBinds.hs
- compiler/typecheck/TcDeriv.hs 1 addition, 1 deletioncompiler/typecheck/TcDeriv.hs
- compiler/typecheck/TcHsType.hs 1 addition, 1 deletioncompiler/typecheck/TcHsType.hs
- testsuite/tests/th/T17688a.hs 10 additions, 0 deletionstestsuite/tests/th/T17688a.hs
- testsuite/tests/th/T17688a.stderr 1 addition, 0 deletionstestsuite/tests/th/T17688a.stderr
- testsuite/tests/th/T17688b.hs 15 additions, 0 deletionstestsuite/tests/th/T17688b.hs
- testsuite/tests/th/T17688b.stderr 2 additions, 0 deletionstestsuite/tests/th/T17688b.stderr
- testsuite/tests/th/all.T 2 additions, 0 deletionstestsuite/tests/th/all.T
Loading
Please register or sign in to comment