Skip to content

Commit

Permalink
treat const as let in for-of loops to work around HtmlUnit/htmlunit#449
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Apr 20, 2022
1 parent a859b88 commit 691fb57
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/org/mozilla/javascript/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 691fb57

Please sign in to comment.