--- old/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java 2016-03-18 14:43:35.682023837 +0100 +++ new/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java 2016-03-18 14:43:35.534023842 +0100 @@ -3320,8 +3320,10 @@ final boolean needsScope = identSymbol.isScope(); if (init == null) { - if (needsScope && varNode.isBlockScoped()) { - // block scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ) + // Block-scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ). + // However, don't do this for CONST which always has an initializer except in the special case of + // for-in/of loops, in which it is initialized in the loop header and should be left untouched here. + if (needsScope && varNode.isLet()) { method.loadCompilerConstant(SCOPE); method.loadUndefined(Type.OBJECT); final int flags = getScopeCallSiteFlags(identSymbol) | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);