< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java

Print this page

        

@@ -252,16 +252,16 @@
     @Override
     public Node leaveForNode(final ForNode forNode) {
         ForNode newForNode = forNode;
 
         final Expression test = forNode.getTest();
-        if (!forNode.isForIn() && isAlwaysTrue(test)) {
+        if (!forNode.isForIn() && !forNode.isForOf() && isAlwaysTrue(test)) {
             newForNode = forNode.setTest(lc, null);
         }
 
         newForNode = checkEscape(newForNode);
-        if(!es6 && newForNode.isForIn()) {
+        if(!es6 && (newForNode.isForIn() || newForNode.isForOf())) {
             // Wrap it in a block so its internally created iterator is restricted in scope, unless we are running
             // in ES6 mode, in which case the parser already created a block to capture let/const declarations.
             addStatementEnclosedInBlock(newForNode);
         } else {
             addStatement(newForNode);
< prev index next >