for-in or for-of expression is evaluated before loop back edge

This commit is contained in:
Anders Hejlsberg
2019-09-15 11:07:51 -07:00
parent 945babbaac
commit d26afd7273

View File

@@ -1032,12 +1032,12 @@ namespace ts {
function bindForInOrForOfStatement(node: ForInOrOfStatement): void {
const preLoopLabel = createLoopLabel();
const postLoopLabel = createBranchLabel();
bind(node.expression);
addAntecedent(preLoopLabel, currentFlow);
currentFlow = preLoopLabel;
if (node.kind === SyntaxKind.ForOfStatement) {
bind(node.awaitModifier);
}
bind(node.expression);
addAntecedent(postLoopLabel, currentFlow);
bind(node.initializer);
if (node.initializer.kind !== SyntaxKind.VariableDeclarationList) {