]> git.kaiwu.me - njs.git/commit
Parser: report an invalid "for-in" target as a SyntaxError
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 1 Sep 2026 01:31:20 +0000 (18:31 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 4 Sep 2026 20:56:37 +0000 (13:56 -0700)
commitab709e37d0509c03a8ee71d67b6798f0bbbc5641
tree13927b5ffe35cb96cfcab97f67c93fbc4a30ddf0
parentb16eec01885cf8f5849f1be056b590e4d1217531
Parser: report an invalid "for-in" target as a SyntaxError

Previously, an invalid for-in target was a ReferenceError when the
initializer happened to parse as a LeftHandSideExpression and a SyntaxError
otherwise, so the same target changed class once parenthesized:

    for (a = 1 in {});     SyntaxError
    for ((a = 1) in {});   ReferenceError

The fix is to report a SyntaxError for both, as the specification and V8 do.
The type is observable through Function(), so this is a compatibility change.
njs keeps ReferenceError for invalid assignment targets elsewhere.
src/njs_parser.c
src/test/njs_unit_test.c