8185257: Nashorn AST is missing nodes when a for-loop contains a VariableDeclarationList

Var declaration in for loop removed from block scope in es6 mode

Reviewed-by: hannesw, sundar
This commit is contained in:
Srinivas Dama 2017-09-26 07:00:43 +05:30 committed by Srinivas Dama
parent 551d0689ed
commit 2dc0eaaa4b
4 changed files with 96 additions and 1 deletions

View file

@ -2053,10 +2053,18 @@ public class Parser extends AbstractParser implements Loggable {
if (outer != null) {
restoreBlock(outer);
if (body != null) {
List<Statement> statements = new ArrayList<>();
for (final Statement var : outer.getStatements()) {
if(var instanceof VarNode && !((VarNode)var).isBlockScoped()) {
appendStatement(var);
}else {
statements.add(var);
}
}
appendStatement(new BlockStatement(forLine, new Block(
outer.getToken(),
body.getFinish(),
outer.getStatements())));
statements)));
}
}
}