From 2570f8e7451ae301404ef5bd6c7603d60c826a2b Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Mon, 18 May 2020 13:14:17 +0200 Subject: [PATCH] Move an assertion after post processing. (#3754) Fixes #3752. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/parser/js/js-parser.c | 14 +++++++------- tests/jerry/es2015/regresssion-test-issue-3727.js | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 tests/jerry/es2015/regresssion-test-issue-3727.js diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index 6778ce94a..3dd23f005 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -2183,13 +2183,6 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */ parser_parse_statements (&context); - /* When the parsing is successful, only the - * dummy value can be remained on the stack. */ - JERRY_ASSERT (context.stack_top_uint8 == CBC_MAXIMUM_BYTE_VALUE - && context.stack.last_position == 1 - && context.stack.first_p != NULL - && context.stack.first_p->next_p == NULL - && context.stack.last_p == NULL); JERRY_ASSERT (context.last_statement.current_p == NULL); JERRY_ASSERT (context.last_cbc_opcode == PARSER_CBC_UNAVAILABLE); @@ -2206,6 +2199,13 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */ compiled_code_p = parser_post_processing (&context); parser_list_free (&context.literal_pool); + /* When parsing is successful, only the dummy value can be remained on the stack. */ + JERRY_ASSERT (context.stack_top_uint8 == CBC_MAXIMUM_BYTE_VALUE + && context.stack.last_position == 1 + && context.stack.first_p != NULL + && context.stack.first_p->next_p == NULL + && context.stack.last_p == NULL); + JERRY_ASSERT (arg_list_p != NULL || !(context.status_flags & PARSER_ARGUMENTS_NEEDED)); #if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) diff --git a/tests/jerry/es2015/regresssion-test-issue-3727.js b/tests/jerry/es2015/regresssion-test-issue-3727.js new file mode 100644 index 000000000..64b897b99 --- /dev/null +++ b/tests/jerry/es2015/regresssion-test-issue-3727.js @@ -0,0 +1,15 @@ +// 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("a = 5, b, c = function() { for (var a = 0; a < 4; a++) ; return a; } ()", "eval ('super (a, b, c, d)')")