Skip to content

Commit 356c3c3

Browse files
author
Robert Fancsik
committed
Const literal marker should be processed before group assignment marker
This patch fixes #4925. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent e9da834 commit 356c3c3

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,16 +3420,16 @@ parser_process_binary_assignment_token (parser_context_t *context_p, /**< contex
34203420
#if JERRY_ESNEXT
34213421
bool group_expr_assingment = false;
34223422

3423-
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_GROUP_EXPR))
3423+
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_CONST))
34243424
{
3425-
group_expr_assingment = true;
34263425
parser_stack_pop_uint8 (context_p);
3426+
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_ASSIGN_CONST_ERROR);
34273427
}
34283428

3429-
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_CONST))
3429+
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_GROUP_EXPR))
34303430
{
3431+
group_expr_assingment = true;
34313432
parser_stack_pop_uint8 (context_p);
3432-
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_ASSIGN_CONST_ERROR);
34333433
}
34343434
#endif /* JERRY_ESNEXT */
34353435

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+
for (const i= 0;;)
17+
(i) = 5;
18+
assert(false);
19+
} catch (e) {
20+
assert(e instanceof TypeError);
21+
}

0 commit comments

Comments
 (0)