Skip to content

Commit d0e8629

Browse files
rerobikadbatyai
authored andcommitted
Support nested destructuring patterns in catch header (#3488)
This patch fixes #3433. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
1 parent 1725e01 commit d0e8629

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,13 +1922,13 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
19221922
#endif /* ENABLED (JERRY_ES2015) */
19231923

19241924
lexer_next_token (context_p);
1925-
#if ENABLED (JERRY_ES2015)
1926-
}
1927-
#endif /* ENABLED (JERRY_ES2015) */
19281925

19291926
#ifndef JERRY_NDEBUG
1930-
JERRY_ASSERT (block_found);
1927+
JERRY_ASSERT (block_found);
19311928
#endif /* !JERRY_NDEBUG */
1929+
#if ENABLED (JERRY_ES2015)
1930+
}
1931+
#endif /* ENABLED (JERRY_ES2015) */
19321932

19331933
if (context_p->token.type != LEXER_RIGHT_PAREN)
19341934
{

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,8 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
829829

830830
lexer_next_token (context_p);
831831

832-
if (binding_type == SCANNER_BINDING_CATCH)
832+
if (binding_type == SCANNER_BINDING_CATCH && context_p->stack_top_uint8 == SCAN_STACK_CATCH_STATEMENT)
833833
{
834-
JERRY_ASSERT (context_p->stack_top_uint8 == SCAN_STACK_CATCH_STATEMENT);
835-
836834
scanner_pop_binding_list (scanner_context_p);
837835

838836
if (context_p->token.type != LEXER_RIGHT_PAREN)

tests/jerry/es2015/try-pattern.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,19 @@ try {
7171
} catch (e) {
7272
assert(e instanceof ReferenceError)
7373
}
74+
75+
try {
76+
throw [{a : 5}];
77+
} catch([{a}]) {
78+
assert(a === 5);
79+
}
80+
81+
var catchReached = false;
82+
try {
83+
throw [{}];
84+
assert(false);
85+
} catch([{}]) {
86+
catchReached = true;
87+
}
88+
89+
assert(catchReached);

0 commit comments

Comments
 (0)