mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 22:22:34 +03:00
fix(es/compat): Fix handling of op-assignment in generator
(#6036)
This commit is contained in:
parent
5df3eb1f43
commit
7554482205
10
crates/swc/tests/exec/issues-5xxx/5994/exec.mjs
Normal file
10
crates/swc/tests/exec/issues-5xxx/5994/exec.mjs
Normal 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());
|
@ -617,15 +617,14 @@ impl VisitMut for Generator {
|
||||
if node.op != op!("=") {
|
||||
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 = Box::new(Expr::Bin(BinExpr {
|
||||
*e = Expr::Assign(AssignExpr {
|
||||
span: node.right.span(),
|
||||
op,
|
||||
left: Box::new(Expr::Ident(left_of_right)),
|
||||
op: node.op,
|
||||
left: left_of_right.into(),
|
||||
right: node.right.take(),
|
||||
}));
|
||||
});
|
||||
} else {
|
||||
node.right.visit_mut_with(self);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user