Skip to content

Commit 52debe8

Browse files
authored
Fix arrow function parsing (#5093)
This fixes #5085 JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi [email protected]
1 parent 514fa67 commit 52debe8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

jerry-core/parser/js/js-parser.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,7 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
28292829
JERRY_ASSERT (context_p->token.type == LEXER_ARROW);
28302830

28312831
lexer_next_token (context_p);
2832+
bool next_token_needed = false;
28322833

28332834
if (context_p->token.type == LEXER_LEFT_BRACE)
28342835
{
@@ -2839,7 +2840,7 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
28392840

28402841
/* Unlike normal function, arrow functions consume their close brace. */
28412842
JERRY_ASSERT (context_p->token.type == LEXER_RIGHT_BRACE);
2842-
lexer_next_token (context_p);
2843+
next_token_needed = true;
28432844
}
28442845
else
28452846
{
@@ -2878,6 +2879,11 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
28782879

28792880
parser_restore_context (context_p, &saved_context);
28802881

2882+
if (next_token_needed)
2883+
{
2884+
lexer_next_token (context_p);
2885+
}
2886+
28812887
return compiled_code_p;
28822888
} /* parser_parse_arrow_function */
28832889

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
async () => {}
16+
await Symbol;
17+
class B{}

0 commit comments

Comments
 (0)