]> git.kaiwu.me - njs.git/commit
Corrected error message when parsing "var" inside "for".
authorValentin Bartenev <vbart@nginx.com>
Thu, 2 May 2019 08:08:44 +0000 (11:08 +0300)
committerValentin Bartenev <vbart@nginx.com>
Thu, 2 May 2019 08:08:44 +0000 (11:08 +0300)
commitf10778faebda160ddbdebee65e1fe2c074b5a44f
treef850ea0b59c3b306945a3899cf1ef3841650c519
parentfd24a4ee8a9328fd24e72e4e21028491a7f0f2b8
Corrected error message when parsing "var" inside "for".

The "var_in" flag indicates parsing inside the "for" statement with expectation
of the "in" token, but it doesn't define the loop as a for-in one.  In fact,
that's unknown at the moment when this particular error message is emitted.

As a result, the following code:

  for (var eval = 10; eval; eval--);

produces the error message about for-in loop:

  SyntaxError: Identifier "eval" is forbidden in for-in var declaration

Actually, according to the specification "eval" isn't a keyword and shouldn't
cause any errors here.  But this bug is beyond the scope of the current fix.
njs/njs_parser.c
njs/test/njs_unit_test.c