@@ -22981,7 +22981,7 @@ static int js_parse_check_duplicate_parameter(JSParseState *s, JSAtom name)
22981
22981
return js_parse_error(s, "Duplicate parameter name not allowed in this context");
22982
22982
}
22983
22983
22984
- static JSAtom js_parse_destructuring_var(JSParseState *s, int tok, int is_arg)
22984
+ static JSAtom js_parse_destructuring_var(JSParseState *s, int tok, bool is_arg)
22985
22985
{
22986
22986
JSAtom name;
22987
22987
@@ -23005,9 +23005,11 @@ static JSAtom js_parse_destructuring_var(JSParseState *s, int tok, int is_arg)
23005
23005
23006
23006
/* Return -1 if error, 0 if no initializer, 1 if an initializer is
23007
23007
present at the top level. */
23008
- static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg,
23009
- int hasval, int has_ellipsis,
23010
- bool allow_initializer, bool export_flag)
23008
+ static int js_parse_destructuring_element(JSParseState *s, int tok,
23009
+ bool is_arg, bool hasval,
23010
+ int has_ellipsis, // tri-state
23011
+ bool allow_initializer,
23012
+ bool export_flag)
23011
23013
{
23012
23014
int label_parse, label_assign, label_done, label_lvalue, depth_lvalue;
23013
23015
int start_addr, assign_addr;
@@ -23623,7 +23625,7 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
23623
23625
{
23624
23626
int skip_bits;
23625
23627
if (js_parse_skip_parens_token(s, &skip_bits, false) == '=') {
23626
- if (js_parse_destructuring_element(s, 0, 0 , false, skip_bits & SKIP_HAS_ELLIPSIS, true, false) < 0)
23628
+ if (js_parse_destructuring_element(s, 0, false , false, skip_bits & SKIP_HAS_ELLIPSIS, true, false) < 0)
23627
23629
return -1;
23628
23630
} else {
23629
23631
if (s->token.val == '{') {
@@ -25182,7 +25184,7 @@ static __exception int js_parse_var(JSParseState *s, int parse_flags, int tok,
25182
25184
if ((s->token.val == '[' || s->token.val == '{')
25183
25185
&& js_parse_skip_parens_token(s, &skip_bits, false) == '=') {
25184
25186
emit_op(s, OP_undefined);
25185
- if (js_parse_destructuring_element(s, tok, 0 , true, skip_bits & SKIP_HAS_ELLIPSIS, true, export_flag) < 0)
25187
+ if (js_parse_destructuring_element(s, tok, false , true, skip_bits & SKIP_HAS_ELLIPSIS, true, export_flag) < 0)
25186
25188
return -1;
25187
25189
} else {
25188
25190
return js_parse_error(s, "variable name expected");
@@ -25304,7 +25306,7 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name,
25304
25306
25305
25307
if (!(s->token.val == TOK_IDENT && !s->token.u.ident.is_reserved)) {
25306
25308
if (s->token.val == '[' || s->token.val == '{') {
25307
- if (js_parse_destructuring_element(s, tok, 0 , true, -1, false, false) < 0)
25309
+ if (js_parse_destructuring_element(s, tok, false , true, -1, false, false) < 0)
25308
25310
return -1;
25309
25311
has_destructuring = true;
25310
25312
} else {
@@ -25332,7 +25334,7 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name,
25332
25334
int skip_bits;
25333
25335
if ((s->token.val == '[' || s->token.val == '{')
25334
25336
&& ((tok1 = js_parse_skip_parens_token(s, &skip_bits, false)) == TOK_IN || tok1 == TOK_OF)) {
25335
- if (js_parse_destructuring_element(s, 0, 0 , true, skip_bits & SKIP_HAS_ELLIPSIS, true, false) < 0)
25337
+ if (js_parse_destructuring_element(s, 0, false , true, skip_bits & SKIP_HAS_ELLIPSIS, true, false) < 0)
25336
25338
return -1;
25337
25339
} else {
25338
25340
int lvalue_label;
@@ -25586,7 +25588,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
25586
25588
case TOK_VAR:
25587
25589
if (next_token(s))
25588
25590
goto fail;
25589
- if (js_parse_var(s, true , tok, false))
25591
+ if (js_parse_var(s, PF_IN_ACCEPTED , tok, /*export_flag*/ false))
25590
25592
goto fail;
25591
25593
if (js_parse_expect_semi(s))
25592
25594
goto fail;
@@ -25749,7 +25751,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
25749
25751
if (tok == TOK_VAR || tok == TOK_LET || tok == TOK_CONST) {
25750
25752
if (next_token(s))
25751
25753
goto fail;
25752
- if (js_parse_var(s, false , tok, false))
25754
+ if (js_parse_var(s, 0 , tok, /*export_flag*/ false))
25753
25755
goto fail;
25754
25756
} else {
25755
25757
if (js_parse_expr2(s, false))
@@ -26011,7 +26013,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
26011
26013
if (!(s->token.val == TOK_IDENT && !s->token.u.ident.is_reserved)) {
26012
26014
if (s->token.val == '[' || s->token.val == '{') {
26013
26015
/* XXX: TOK_LET is not completely correct */
26014
- if (js_parse_destructuring_element(s, TOK_LET, 0 , true, -1, true, false) < 0)
26016
+ if (js_parse_destructuring_element(s, TOK_LET, false , true, -1, true, false) < 0)
26015
26017
goto fail;
26016
26018
} else {
26017
26019
js_parse_error(s, "identifier expected");
@@ -28246,7 +28248,7 @@ static __exception int js_parse_export(JSParseState *s)
28246
28248
case TOK_VAR:
28247
28249
case TOK_LET:
28248
28250
case TOK_CONST:
28249
- return js_parse_var(s, true , tok, true);
28251
+ return js_parse_var(s, PF_IN_ACCEPTED , tok, /*export_flag*/ true);
28250
28252
default:
28251
28253
return js_parse_error(s, "invalid export syntax");
28252
28254
}
@@ -32959,7 +32961,7 @@ static __exception int js_parse_function_decl2(JSParseState *s,
32959
32961
emit_op(s, OP_get_arg);
32960
32962
emit_u16(s, idx);
32961
32963
}
32962
- has_initializer = js_parse_destructuring_element(s, fd->has_parameter_expressions ? TOK_LET : TOK_VAR, 1 , true, -1, true, false);
32964
+ has_initializer = js_parse_destructuring_element(s, fd->has_parameter_expressions ? TOK_LET : TOK_VAR, true , true, -1, true, false);
32963
32965
if (has_initializer < 0)
32964
32966
goto fail;
32965
32967
if (has_initializer)
0 commit comments