Skip to content

Commit 1414e9b

Browse files
authored
Fix invalid AssignmentExpression lookahead in parser_process_group_expression (#3846)
This patch fixes #3845. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 1322e08 commit 1414e9b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

jerry-core/parser/js/js-parser-expr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,8 @@ parser_process_group_expression (parser_context_t *context_p, /**< context */
34073407
with a single indentifier in it. e.g.: (a) = function () {} */
34083408
if (JERRY_UNLIKELY (context_p->token.type == LEXER_ASSIGN
34093409
&& PARSER_IS_PUSH_LITERALS_WITH_THIS (context_p->last_cbc_opcode)
3410-
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL))
3410+
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL
3411+
&& parser_is_assignment_expr (context_p)))
34113412
{
34123413
parser_stack_push_uint8 (context_p, LEXER_ASSIGN_GROUP_EXPR);
34133414
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
try {
16+
eval(`typeof (a) = 1 === 'undefined';`);
17+
assert(false);
18+
} catch (e) {
19+
assert(e instanceof ReferenceError);
20+
}
21+

0 commit comments

Comments
 (0)