[Git][ghc/ghc][wip/expand-do] Expands `do` blocks before typechecking using the `HsExpansion` philosophy
Apoorv Ingle (@ani)
gitlab at gitlab.haskell.org
Mon Oct 2 17:53:49 UTC 2023
Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC
Commits:
b94a213d by Apoorv Ingle at 2023-10-02T10:46:23-05:00
Expands `do` blocks before typechecking using the `HsExpansion` philosophy
- Fixes #18324 #20020 #23147 #22788 #15598 #22086
- Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Match` explains change in detail
- New datatypes to make this expansion work:
`GHC.Hs.Expr.XXExprGhcRn`: It contains
1. Expansion bits for Statements (`ExpansionStmt`) and Patterns (`ExpansionPat`)
2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack
- `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated
This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam`
- Ensures warnings such as
1. Pattern mach checks
2. Failable patterns
3. non-() return in body statements are preserved
- Expansions inside Template haskell also work without issues.
- Testcases:
* T18324 T20020 T23147 T22788 T15598 T22086
* T23147b (error message check),
* DoubleMatch (match inside a match for pmc check)
* pattern-fails (check pattern match with non-refutable pattern, eg. newtype)
* Simple-rec (rec statements inside do statment)
* T22788 (code snippet from #22788)
* DoExpanion1 (Error messages for body statments)
* DoExpansion2 (Error messages for bind statements)
* DoExpansion3 (Error messages for let statements)
- - - - -
30 changed files:
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Arrows.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/Types/Basic.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b94a213d6451eb444afc1884852c3729fff2374f
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b94a213d6451eb444afc1884852c3729fff2374f
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/20231002/1da217e4/attachment.html>
More information about the ghc-commits
mailing list