Skip to content

Commit f3a420b

Browse files
authored
Fix class static block opening brace parsing (#4942)
The next character should not be consumed after finding the static block opening brace. This patch fixes #4916. JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru [email protected]
1 parent 69f3097 commit f3a420b

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3273,14 +3273,17 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
32733273
#endif /* JERRY_ESNEXT */
32743274
case LIT_CHAR_LEFT_BRACE:
32753275
{
3276-
if (ident_opts & (LEXER_OBJ_IDENT_CLASS_NO_STATIC | LEXER_OBJ_IDENT_CLASS_PRIVATE))
3276+
const uint32_t static_block_flags =
3277+
(LEXER_OBJ_IDENT_CLASS_NO_STATIC | LEXER_OBJ_IDENT_CLASS_PRIVATE | LEXER_OBJ_IDENT_CLASS_IDENTIFIER);
3278+
3279+
if ((ident_opts & static_block_flags) == LEXER_OBJ_IDENT_CLASS_IDENTIFIER)
32773280
{
3278-
break;
3281+
context_p->token.type = LEXER_LEFT_BRACE;
3282+
lexer_consume_next_character (context_p);
3283+
return;
32793284
}
32803285

3281-
context_p->token.type = LEXER_LEFT_BRACE;
3282-
lexer_consume_next_character (context_p);
3283-
return;
3286+
break;
32843287
}
32853288
case LIT_CHAR_RIGHT_BRACE:
32863289
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 a = { get {(param)} }`);
17+
assert(false);
18+
}
19+
catch (e) {
20+
assert(e instanceof SyntaxError);
21+
}

0 commit comments

Comments
 (0)