Skip to content

Commit e9da834

Browse files
author
Robert Fancsik
authored
Fix async identifier parsing in class field position (#4949)
This patch fixes #4927 JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 47d025c commit e9da834

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ scanner_scan_all (parser_context_t *context_p) /**< context */
28612861
continue;
28622862
}
28632863

2864-
if (literal_pool_flags != SCANNER_LITERAL_POOL_FUNCTION)
2864+
if (literal_pool_flags & SCANNER_LITERAL_POOL_GENERATOR)
28652865
{
28662866
scanner_raise_error (context_p);
28672867
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
class C1 { async }
16+
class C2 { async; constructor() {} }
17+
class C3 { async = 5.1; constructor() {} }
18+
19+
assert((new C1).async === undefined);
20+
assert((new C2).async === undefined);
21+
assert((new C3).async === 5.1);
22+
23+
try {
24+
eval('class C1 { async* }');
25+
assert(false);
26+
} catch (e) {
27+
assert(e instanceof SyntaxError);
28+
}
29+

0 commit comments

Comments
 (0)