From 3900152631a67e917937fddd8cb82f3915c369f0 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Tue, 21 Apr 2020 11:59:30 +0200 Subject: [PATCH] Fix delayed variable creation for function declarations. (#3687) Fixes #3658. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/parser/js/js-scanner-util.c | 3 ++- .../es2015/regression-test-issue-3658.js | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/jerry/es2015/regression-test-issue-3658.js diff --git a/jerry-core/parser/js/js-scanner-util.c b/jerry-core/parser/js/js-scanner-util.c index 58a0d5cc2..c1e86c172 100644 --- a/jerry-core/parser/js/js-scanner-util.c +++ b/jerry-core/parser/js/js-scanner-util.c @@ -525,7 +525,8 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */ } #if ENABLED (JERRY_ES2015) - if (is_function && (type & (SCANNER_LITERAL_IS_FUNC | SCANNER_LITERAL_IS_LOCAL)) == SCANNER_LITERAL_IS_FUNC) + if (is_function + && (type & (SCANNER_LITERAL_IS_FUNC | SCANNER_LITERAL_IS_FUNC_DECLARATION)) == SCANNER_LITERAL_IS_FUNC) { if (prev_literal_pool_p == NULL && (context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL) diff --git a/tests/jerry/es2015/regression-test-issue-3658.js b/tests/jerry/es2015/regression-test-issue-3658.js new file mode 100644 index 000000000..ed4299945 --- /dev/null +++ b/tests/jerry/es2015/regression-test-issue-3658.js @@ -0,0 +1,24 @@ +// 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. + +function g({ + ["y"]: { + a + } +}) +{ + { + function a() {} + } +}