summaryrefslogtreecommitdiff
path: root/testsuite/tests/parser
diff options
context:
space:
mode:
authorAlp Mestanogullari <alpmestan@gmail.com>2020-03-13 17:41:37 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-14 21:30:52 -0400
commit118e1c3da622f17c67b4e0fbc12ed7c7084055dc (patch)
tree2468e0ab92966c06663c95b2de7f2e0702432312 /testsuite/tests/parser
parent7f0b671ee8a65913891c07f157b21d77d6c63036 (diff)
downloadhaskell-118e1c3da622f17c67b4e0fbc12ed7c7084055dc.tar.gz
compiler: re-engineer the treatment of rebindable if
Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard.
Diffstat (limited to 'testsuite/tests/parser')
-rw-r--r--testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr85
1 files changed, 45 insertions, 40 deletions
diff --git a/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr b/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr
index 80fc356925..a9081bf7eb 100644
--- a/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr
+++ b/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr
@@ -540,14 +540,15 @@
(NoExtField)
({ <no location info> }
(XExpr
- (HsWrap
- (WpTyApp
- (TyConApp
- ({abstract:TyCon})
- []))
- (HsConLikeOut
- (NoExtField)
- ({abstract:ConLike})))))
+ (WrapExpr
+ (HsWrap
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ []))
+ (HsConLikeOut
+ (NoExtField)
+ ({abstract:ConLike}))))))
({ <no location info> }
(HsVar
(NoExtField)
@@ -564,14 +565,15 @@
(NoExtField)
({ <no location info> }
(XExpr
- (HsWrap
- (WpTyApp
- (TyConApp
- ({abstract:TyCon})
- []))
- (HsConLikeOut
- (NoExtField)
- ({abstract:ConLike})))))
+ (WrapExpr
+ (HsWrap
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ []))
+ (HsConLikeOut
+ (NoExtField)
+ ({abstract:ConLike}))))))
({ <no location info> }
(HsVar
(NoExtField)
@@ -588,14 +590,15 @@
(NoExtField)
({ <no location info> }
(XExpr
- (HsWrap
- (WpTyApp
- (TyConApp
- ({abstract:TyCon})
- []))
- (HsConLikeOut
- (NoExtField)
- ({abstract:ConLike})))))
+ (WrapExpr
+ (HsWrap
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ []))
+ (HsConLikeOut
+ (NoExtField)
+ ({abstract:ConLike}))))))
({ <no location info> }
(HsVar
(NoExtField)
@@ -603,14 +606,15 @@
{Var: $krep})))))
({ <no location info> }
(XExpr
- (HsWrap
- (WpTyApp
- (TyConApp
- ({abstract:TyCon})
- []))
- (HsConLikeOut
- (NoExtField)
- ({abstract:ConLike})))))))))))))))))))))
+ (WrapExpr
+ (HsWrap
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ []))
+ (HsConLikeOut
+ (NoExtField)
+ ({abstract:ConLike}))))))))))))))))))))))
,({ <no location info> }
(VarBind
(NoExtField)
@@ -632,14 +636,15 @@
{Var: DumpTypecheckedAst.$tcPeano})))))
({ <no location info> }
(XExpr
- (HsWrap
- (WpTyApp
- (TyConApp
- ({abstract:TyCon})
- []))
- (HsConLikeOut
- (NoExtField)
- ({abstract:ConLike})))))))))
+ (WrapExpr
+ (HsWrap
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ []))
+ (HsConLikeOut
+ (NoExtField)
+ ({abstract:ConLike}))))))))))
,({ <no location info> }
(VarBind
(NoExtField)