Skip to content

Commit a7e24fe

Browse files
authored
Const literal marker should be processed before group assignment marker (#4948)
This patch fixes #4925. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 82ca949 commit a7e24fe

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -3486,16 +3486,16 @@ parser_process_binary_assignment_token (parser_context_t *context_p, /**< contex
34863486

34873487
bool group_expr_assingment = false;
34883488

3489-
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_GROUP_EXPR))
3489+
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_CONST))
34903490
{
3491-
group_expr_assingment = true;
34923491
parser_stack_pop_uint8 (context_p);
3492+
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_ASSIGN_CONST_ERROR);
34933493
}
34943494

3495-
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_CONST))
3495+
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_GROUP_EXPR))
34963496
{
3497+
group_expr_assingment = true;
34973498
parser_stack_pop_uint8 (context_p);
3498-
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_ASSIGN_CONST_ERROR);
34993499
}
35003500

35013501
if (index == PARSER_INVALID_LITERAL_INDEX)
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)