Fix #15344: use fail when desugaring applicative-do
Applicative-do has a bug where it fails to use the monadic fail method when desugaring patternmatches which can fail. See #15344. This patch fixes that problem. It required more rewiring than I had expected. Applicative-do happens mostly in the renamer; that's where decisions about scheduling are made. This schedule is then carried through the typechecker and into the desugarer which performs the actual translation. Fixing this bug required sending information about the fail method from the renamer, through the type checker and into the desugarer. Previously, the desugarer didn't have enough information to actually desugar pattern matches correctly. As a side effect, we also fix #16628, where GHC wouldn't catch missing MonadFail instances with -XApplicativeDo.
Showing
- compiler/GHC/Hs/Expr.hs 22 additions, 13 deletionscompiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Utils.hs 4 additions, 4 deletionscompiler/GHC/Hs/Utils.hs
- compiler/deSugar/Coverage.hs 2 additions, 1 deletioncompiler/deSugar/Coverage.hs
- compiler/deSugar/DsExpr.hs 13 additions, 13 deletionscompiler/deSugar/DsExpr.hs
- compiler/hieFile/HieAst.hs 1 addition, 1 deletioncompiler/hieFile/HieAst.hs
- compiler/rename/RnExpr.hs 85 additions, 12 deletionscompiler/rename/RnExpr.hs
- compiler/typecheck/TcHsSyn.hs 8 additions, 6 deletionscompiler/typecheck/TcHsSyn.hs
- compiler/typecheck/TcMatches.hs 21 additions, 9 deletionscompiler/typecheck/TcMatches.hs
- testsuite/tests/ado/T13242a.stderr 3 additions, 8 deletionstestsuite/tests/ado/T13242a.stderr
- testsuite/tests/ado/T15344.hs 10 additions, 0 deletionstestsuite/tests/ado/T15344.hs
- testsuite/tests/ado/T15344.stdout 1 addition, 0 deletionstestsuite/tests/ado/T15344.stdout
- testsuite/tests/ado/T16628.hs 14 additions, 0 deletionstestsuite/tests/ado/T16628.hs
- testsuite/tests/ado/T16628.stderr 15 additions, 0 deletionstestsuite/tests/ado/T16628.stderr
- testsuite/tests/ado/ado001.stdout 1 addition, 1 deletiontestsuite/tests/ado/ado001.stdout
- testsuite/tests/ado/ado008.hs 187 additions, 0 deletionstestsuite/tests/ado/ado008.hs
- testsuite/tests/ado/all.T 3 additions, 0 deletionstestsuite/tests/ado/all.T
Loading
Please register or sign in to comment