Skip to content

Commit e37b414

Browse files
committed
Fix super keyword parsing for arrow functions.
This patch fixes #2657. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 0c20f8e commit e37b414

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
14071407
{
14081408
if ((lexer_check_next_character (context_p, LIT_CHAR_DOT)
14091409
|| lexer_check_next_character (context_p, LIT_CHAR_LEFT_SQUARE))
1410-
&& context_p->status_flags & (PARSER_CLASS_HAS_SUPER | PARSER_IS_ARROW_FUNCTION))
1410+
&& context_p->status_flags & (PARSER_CLASS_HAS_SUPER))
14111411
{
14121412
if (!LEXER_IS_BINARY_LVALUE_TOKEN (context_p->stack_top_uint8))
14131413
{
@@ -1426,8 +1426,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
14261426
}
14271427

14281428
if (lexer_check_next_character (context_p, LIT_CHAR_LEFT_PAREN)
1429-
&& (context_p->status_flags & PARSER_CLASS_HAS_SUPER)
1430-
&& (context_p->status_flags & (PARSER_IS_ARROW_FUNCTION | PARSER_CLASS_CONSTRUCTOR)))
1429+
&& ((context_p->status_flags & PARSER_CLASS_CONSTRUCTOR_SUPER) == PARSER_CLASS_CONSTRUCTOR_SUPER))
14311430
{
14321431
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_CONSTRUCTOR_SUPER);
14331432
break;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
try {
16+
eval ("var Mixin1 = (superclass) => class extends super.lass {};");
17+
assert (false);
18+
} catch (e) {
19+
assert (e instanceof SyntaxError);
20+
}

0 commit comments

Comments
 (0)