Skip to content

Commit

Permalink
Fix PropertyDefinition parsing in ObjectInitializer
Browse files Browse the repository at this point in the history
This patch fixes jerryscript-project#3822.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
  • Loading branch information
rerobika committed Jun 2, 2020
1 parent d06c3a7 commit 8319771
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jerry-core/parser/js/js-parser-expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3215,9 +3215,10 @@ parser_parse_object_initializer (parser_context_t *context_p, /**< context */
parser_raise_error (context_p, PARSER_ERR_COLON_EXPECTED);
}

if (context_p->token.type != LEXER_RIGHT_BRACE
&& context_p->token.type != LEXER_ASSIGN
&& context_p->token.type != LEXER_COMMA)
if ((context_p->token.type != LEXER_RIGHT_BRACE
&& context_p->token.type != LEXER_ASSIGN
&& context_p->token.type != LEXER_COMMA)
|| (context_p->token.lit_location.type != LEXER_IDENT_LITERAL))
{
parser_raise_error (context_p, PARSER_ERR_OBJECT_ITEM_SEPARATOR_EXPECTED);
}
Expand Down
21 changes: 21 additions & 0 deletions tests/jerry/es2015/regression-test-issue-3822.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

try {
eval(`function f ({array, 'a', { value: 'foo', enumerable: true } : 36}){}`);
assert(false);
} catch (e) {
assert(e instanceof SyntaxError);
}

0 comments on commit 8319771

Please # to comment.