Skip to content

Commit

Permalink
fix(es/fixer): Wrap yield expression in await expression (#8357)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #8356
  • Loading branch information
magic-akari authored Nov 29, 2023
1 parent 1853280 commit ff719f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8356/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"jsc": {
"target": "es2017"
}
}
5 changes: 5 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8356/input/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const obj = {
async *asyncYield() {
return await (yield* nestedAsyncYield());
},
};
5 changes: 5 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8356/output/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const obj = {
async *asyncYield () {
return await (yield* nestedAsyncYield());
}
};
4 changes: 3 additions & 1 deletion crates/swc_ecma_transforms_base/src/fixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ impl VisitMut for Fixer<'_> {
self.ctx = old;

match &*expr.arg {
Expr::Cond(..) | Expr::Assign(..) | Expr::Bin(..) => self.wrap(&mut expr.arg),
Expr::Cond(..) | Expr::Assign(..) | Expr::Bin(..) | Expr::Yield(..) => {
self.wrap(&mut expr.arg)
}
_ => {}
}
}
Expand Down

0 comments on commit ff719f0

Please sign in to comment.