From 26c6031530ea79a7b55e18128e3b3b27e99c4432 Mon Sep 17 00:00:00 2001 From: batizdaniel Date: Wed, 22 Dec 2021 14:50:46 +0100 Subject: [PATCH] Fix class literal scan (#4906) This patch fixes #4892 JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu --- jerry-core/parser/js/js-scanner-util.c | 15 +++++---------- .../jerry/es.next/regression-test-issue-4892.js | 16 ++++++++++++++++ tests/test262-esnext-excludelist.xml | 1 - 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 tests/jerry/es.next/regression-test-issue-4892.js diff --git a/jerry-core/parser/js/js-scanner-util.c b/jerry-core/parser/js/js-scanner-util.c index 4df3092ea..a6578daa3 100644 --- a/jerry-core/parser/js/js-scanner-util.c +++ b/jerry-core/parser/js/js-scanner-util.c @@ -1839,17 +1839,12 @@ scanner_push_class_declaration (parser_context_t *context_p, /**< context */ if (class_has_name) { - if (stack_mode == SCAN_STACK_CLASS_STATEMENT) - { - literal_p = scanner_add_literal (context_p, scanner_context_p); - scanner_context_p->active_literal_pool_p->no_declarations++; - } -#if JERRY_MODULE_SYSTEM - else if (is_export_default) - { - literal_p = scanner_add_literal (context_p, scanner_context_p); - scanner_context_p->active_literal_pool_p->no_declarations++; + literal_p = scanner_add_literal (context_p, scanner_context_p); + scanner_context_p->active_literal_pool_p->no_declarations++; +#if JERRY_MODULE_SYSTEM + if (is_export_default) + { scanner_detect_invalid_let (context_p, literal_p); if (literal_p->type & SCANNER_LITERAL_IS_USED) diff --git a/tests/jerry/es.next/regression-test-issue-4892.js b/tests/jerry/es.next/regression-test-issue-4892.js new file mode 100644 index 000000000..d2db48b20 --- /dev/null +++ b/tests/jerry/es.next/regression-test-issue-4892.js @@ -0,0 +1,16 @@ +// 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 MyArray extends class C{} +{}; diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index 801140306..c9e548c02 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -28,7 +28,6 @@ -