Skip to content

Commit 4e89e18

Browse files
authored
Fix parsing of invalid private class properties (#5144)
Raise syntax error instead of failing with an assert JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi [email protected]
1 parent d7e2125 commit 4e89e18

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ static void
405405
parser_check_duplicated_private_field (parser_context_t *context_p, /**< context */
406406
uint8_t opts) /**< options */
407407
{
408-
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL);
408+
if (context_p->token.type != LEXER_LITERAL)
409+
{
410+
parser_raise_error (context_p, PARSER_ERR_EXPRESSION_EXPECTED);
411+
}
409412
JERRY_ASSERT (context_p->private_context_p);
410413
scanner_class_private_member_t *iter = context_p->private_context_p->members_p;
411414

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+
class C { #get [Symbol]; }

tools/cppcheck/suppressions-list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ shiftNegativeLHS:jerry-math/*.c
3131
shiftTooManyBits:jerry-core/*.c
3232
shiftTooManyBitsSigned:jerry-math/*.c
3333
signConversionCond:jerry-core/*.c
34-
uninitvar:jerry-core/parser/js/js-parser-expr.c:3420
34+
uninitvar:jerry-core/parser/js/js-parser-expr.c:3423
3535
uninitvar:tests/unit-core/test-api-objecttype.c:119
3636
unmatchedSuppression:jerry-core/*.inc.h
3737
unreadVariable:jerry-core/*.c

0 commit comments

Comments
 (0)