Fix for-await printing (#5322)

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
This commit is contained in:
Daniel Tschinder
2017-02-15 23:43:06 +01:00
committed by Henry Zhu
parent ff2c24eed2
commit 28853bf190
2 changed files with 4 additions and 4 deletions

View File

@@ -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(")");

View File

@@ -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 []) {}
}