diff options
author | Máté Tokodi <mate.tokodi@szteszoftver.hu> | 2024-02-01 00:34:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 00:34:37 +0100 |
commit | 52debe85898f84a980d18ec09713d43cee3a9f90 (patch) | |
tree | 613e09a81f1ed34727f177709a56ef46e7ff0867 | |
parent | 514fa6735a5d7ff3093571c921120e3487734be9 (diff) |
Fix arrow function parsing (#5093)
This fixes #5085
JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
-rw-r--r-- | jerry-core/parser/js/js-parser.c | 8 | ||||
-rw-r--r-- | tests/jerry/fail/regression-test-issue-5085.js | 17 |
2 files changed, 24 insertions, 1 deletions
diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index ecf7cd39..8f241b6a 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -2829,6 +2829,7 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */ JERRY_ASSERT (context_p->token.type == LEXER_ARROW); lexer_next_token (context_p); + bool next_token_needed = false; if (context_p->token.type == LEXER_LEFT_BRACE) { @@ -2839,7 +2840,7 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */ /* Unlike normal function, arrow functions consume their close brace. */ JERRY_ASSERT (context_p->token.type == LEXER_RIGHT_BRACE); - lexer_next_token (context_p); + next_token_needed = true; } else { @@ -2878,6 +2879,11 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */ parser_restore_context (context_p, &saved_context); + if (next_token_needed) + { + lexer_next_token (context_p); + } + return compiled_code_p; } /* parser_parse_arrow_function */ diff --git a/tests/jerry/fail/regression-test-issue-5085.js b/tests/jerry/fail/regression-test-issue-5085.js new file mode 100644 index 00000000..626aea02 --- /dev/null +++ b/tests/jerry/fail/regression-test-issue-5085.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. + +async () => {} +await Symbol; +class B{} |