Skip to content

Commit e01cfda

Browse files
authored
Check next token before reparsing identifiers in object assignments. (#3756)
Fixes #3735. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent c4d5c2c commit e01cfda

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,14 +3075,20 @@ parser_parse_object_initializer (parser_context_t *context_p, /**< context */
30753075
parser_raise_error (context_p, PARSER_ERR_COLON_EXPECTED);
30763076
}
30773077

3078-
if (context_p->token.type == LEXER_RIGHT_BRACE
3079-
|| context_p->token.type == LEXER_ASSIGN
3080-
|| context_p->token.type == LEXER_COMMA)
3078+
if (context_p->token.type != LEXER_RIGHT_BRACE
3079+
&& context_p->token.type != LEXER_ASSIGN
3080+
&& context_p->token.type != LEXER_COMMA)
30813081
{
3082-
parser_reparse_as_common_identifier (context_p, start_line, start_column);
3083-
lexer_next_token (context_p);
3082+
parser_raise_error (context_p, PARSER_ERR_OBJECT_ITEM_SEPARATOR_EXPECTED);
30843083
}
30853084

3085+
parser_reparse_as_common_identifier (context_p, start_line, start_column);
3086+
lexer_next_token (context_p);
3087+
3088+
JERRY_ASSERT (context_p->token.type == LEXER_RIGHT_BRACE
3089+
|| context_p->token.type == LEXER_ASSIGN
3090+
|| context_p->token.type == LEXER_COMMA);
3091+
30863092
if (flags & PARSER_PATTERN_ARGUMENTS)
30873093
{
30883094
if (context_p->lit_object.literal_p->status_flags & LEXER_FLAG_FUNCTION_ARGUMENT)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
function $({ $ $() {}

0 commit comments

Comments
 (0)