Skip to content

Commit

Permalink
Fix for-await printing (#5322)
Browse files Browse the repository at this point in the history
Only the first for-await was correctly printed all subsequent for-await statements
where printed as for-of as the variable op was changed inside the buildForXStatement
  • Loading branch information
danez authored and hzoo committed Feb 15, 2017
1 parent ff2c24e commit 28853bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/babel-generator/src/generators/statements.js
Expand Up @@ -87,13 +87,13 @@ const buildForXStatement = function (op) {
if (op === "await") {
this.word("await");
this.space();
op = "of";
// do not attempt to change op here, as it will break subsequent for-await statements
}
this.token("(");

this.print(node.left, node);
this.space();
this.word(op);
this.word(op === "await" ? "of" : op);
this.space();
this.print(node.right, node);
this.token(")");
Expand Down
Expand Up @@ -18,11 +18,11 @@ async function a() {
for ({ a } in {}) {}
for ({ a } of []) {}
async function a() {
for ({ a } of []) {}
for await ({ a } of []) {}
}

for (a in {}) {}
for (a of []) {}
async function a() {
for (a of []) {}
for await (a of []) {}
}

0 comments on commit 28853bf

Please sign in to comment.