diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index b86efffad..be871a165 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -2338,7 +2338,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */ case LEXER_KEYW_CLASS: { parser_parse_class (context_p, true); - continue; + goto consume_last_statement; } #endif /* ENABLED (JERRY_ES2015_CLASS) */ @@ -2359,7 +2359,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */ case LEXER_KEYW_FUNCTION: { parser_parse_function_statement (context_p); - continue; + goto consume_last_statement; } case LEXER_KEYW_IF: @@ -2665,6 +2665,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */ parser_raise_error (context_p, PARSER_ERR_SEMICOLON_EXPECTED); } +consume_last_statement: while (true) { switch (context_p->stack_top_uint8) diff --git a/tests/jerry/es2015/regression-test-issue-3151-class.js b/tests/jerry/es2015/regression-test-issue-3151-class.js new file mode 100644 index 000000000..4e8644805 --- /dev/null +++ b/tests/jerry/es2015/regression-test-issue-3151-class.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. + +do class $ { } while (0); diff --git a/tests/jerry/fail/regression-test-issue-3174.js b/tests/jerry/fail/regression-test-issue-3174.js new file mode 100644 index 000000000..e449bc079 --- /dev/null +++ b/tests/jerry/fail/regression-test-issue-3174.js @@ -0,0 +1,17 @@ +// 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. + +if ($) + function $ ( ) { }; +else if ( b ) c diff --git a/tests/jerry/regression-test-issue-3151-function.js b/tests/jerry/regression-test-issue-3151-function.js new file mode 100644 index 000000000..150c79a27 --- /dev/null +++ b/tests/jerry/regression-test-issue-3151-function.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. + +do function $ ( ) { } while (0);