From 691fb57806a74a512142e8897fb4a6a440440a2d Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Wed, 20 Apr 2022 10:47:40 +0200 Subject: [PATCH] treat const as let in for-of loops to work around https://github.com/HtmlUnit/htmlunit/issues/449 --- src/org/mozilla/javascript/Parser.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/org/mozilla/javascript/Parser.java b/src/org/mozilla/javascript/Parser.java index d8310e846d..06ca941cfc 100644 --- a/src/org/mozilla/javascript/Parser.java +++ b/src/org/mozilla/javascript/Parser.java @@ -1593,6 +1593,17 @@ private AstNode forLoopInit(int tt) throws IOException { } else if (tt == Token.VAR || tt == Token.LET) { consumeToken(); init = variables(tt, ts.tokenBeg, false); + + // HtmlUnit - HACK + // allow const in for-of loop's by treating them as let + // see JavaScriptEngine2Test.constInOfLoop() + // + // HtmlUnit - HACK + } else if (tt == Token.CONST) { + consumeToken(); + init = variables(Token.LET, ts.tokenBeg, false); + // HtmlUnit - HACK + } else { init = expr(); }