From 5c677a94496ec55204c4e51b5f90aa998699a1a6 Mon Sep 17 00:00:00 2001 From: hvwyl <594352301@qq.com> Date: Sat, 12 Jul 2025 22:32:30 +0800 Subject: [PATCH] Fix "Private Class Fields Parsing Error" --- jerry-core/parser/js/js-scanner.c | 1 + tests/jerry/regression-test-issue-5017.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/jerry/regression-test-issue-5017.js diff --git a/jerry-core/parser/js/js-scanner.c b/jerry-core/parser/js/js-scanner.c index 30d6e977c6..e5bc2b09e5 100644 --- a/jerry-core/parser/js/js-scanner.c +++ b/jerry-core/parser/js/js-scanner.c @@ -1189,6 +1189,7 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context * scanner_context_p->mode = SCAN_MODE_CLASS_BODY; break; } + case LEXER_HASHMARK: case LEXER_RIGHT_BRACE: { source_p = context_p->source_p - 1; diff --git a/tests/jerry/regression-test-issue-5017.js b/tests/jerry/regression-test-issue-5017.js new file mode 100644 index 0000000000..81efdf62ac --- /dev/null +++ b/tests/jerry/regression-test-issue-5017.js @@ -0,0 +1,19 @@ +// 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. + +class A { + #p = 'something' + #privateMethod() { + } +}