fix(es/compat): Fix handling of op-assignment in generator (#6036)

This commit is contained in:
Donny/강동윤 2022-10-05 00:17:50 +09:00 committed by GitHub
parent 5df3eb1f43
commit 7554482205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -0,0 +1,10 @@
async function b() { return "bar"; }
let x;
let a;
a = async () => { x = ""; x += await b(); return x; }
console.log(await a());

View File

@ -617,15 +617,14 @@ impl VisitMut for Generator {
if node.op != op!("=") { if node.op != op!("=") {
let left_of_right = self.cache_expression(node.left.take().expect_expr()); let left_of_right = self.cache_expression(node.left.take().expect_expr());
let op = node.op.to_update().unwrap();
node.right.visit_mut_with(self); node.right.visit_mut_with(self);
node.right = Box::new(Expr::Bin(BinExpr { *e = Expr::Assign(AssignExpr {
span: node.right.span(), span: node.right.span(),
op, op: node.op,
left: Box::new(Expr::Ident(left_of_right)), left: left_of_right.into(),
right: node.right.take(), right: node.right.take(),
})); });
} else { } else {
node.right.visit_mut_with(self); node.right.visit_mut_with(self);
} }