mirror of
https://github.com/bellard/quickjs.git
synced 2025-05-12 19:14:39 +08:00
fixed destructuring parsing: do it only in assignment expressions
This commit is contained in:
parent
5449fd42d6
commit
1d5e7cf300
15
quickjs.c
15
quickjs.c
@ -24653,12 +24653,6 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
|
|||||||
break;
|
break;
|
||||||
case '{':
|
case '{':
|
||||||
case '[':
|
case '[':
|
||||||
{
|
|
||||||
int skip_bits;
|
|
||||||
if (js_parse_skip_parens_token(s, &skip_bits, FALSE) == '=') {
|
|
||||||
if (js_parse_destructuring_element(s, 0, 0, FALSE, skip_bits & SKIP_HAS_ELLIPSIS, TRUE, FALSE) < 0)
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
if (s->token.val == '{') {
|
if (s->token.val == '{') {
|
||||||
if (js_parse_object_literal(s))
|
if (js_parse_object_literal(s))
|
||||||
return -1;
|
return -1;
|
||||||
@ -24666,8 +24660,6 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
|
|||||||
if (js_parse_array_literal(s))
|
if (js_parse_array_literal(s))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TOK_NEW:
|
case TOK_NEW:
|
||||||
if (next_token(s))
|
if (next_token(s))
|
||||||
@ -25639,7 +25631,7 @@ static __exception int js_parse_cond_expr(JSParseState *s, int parse_flags)
|
|||||||
/* allowed parse_flags: PF_IN_ACCEPTED */
|
/* allowed parse_flags: PF_IN_ACCEPTED */
|
||||||
static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags)
|
static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags)
|
||||||
{
|
{
|
||||||
int opcode, op, scope;
|
int opcode, op, scope, skip_bits;
|
||||||
JSAtom name0 = JS_ATOM_NULL;
|
JSAtom name0 = JS_ATOM_NULL;
|
||||||
JSAtom name;
|
JSAtom name;
|
||||||
|
|
||||||
@ -25816,6 +25808,11 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags)
|
|||||||
return js_parse_function_decl(s, JS_PARSE_FUNC_ARROW,
|
return js_parse_function_decl(s, JS_PARSE_FUNC_ARROW,
|
||||||
JS_FUNC_NORMAL, JS_ATOM_NULL,
|
JS_FUNC_NORMAL, JS_ATOM_NULL,
|
||||||
s->token.ptr);
|
s->token.ptr);
|
||||||
|
} else if ((s->token.val == '{' || s->token.val == '[') &&
|
||||||
|
js_parse_skip_parens_token(s, &skip_bits, FALSE) == '=') {
|
||||||
|
if (js_parse_destructuring_element(s, 0, 0, FALSE, skip_bits & SKIP_HAS_ELLIPSIS, TRUE, FALSE) < 0)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
next:
|
next:
|
||||||
if (s->token.val == TOK_IDENT) {
|
if (s->token.val == TOK_IDENT) {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
test262/test/language/destructuring/binding/keyed-destructuring-property-reference-target-evaluation-order-with-bindings.js:73: Test262Error: Actual [binding::source, binding::sourceKey, sourceKey, get source, binding::defaultValue, binding::varTarget] and expected [binding::source, binding::sourceKey, sourceKey, binding::varTarget, get source, binding::defaultValue] should have the same contents.
|
test262/test/language/destructuring/binding/keyed-destructuring-property-reference-target-evaluation-order-with-bindings.js:73: Test262Error: Actual [binding::source, binding::sourceKey, sourceKey, get source, binding::defaultValue, binding::varTarget] and expected [binding::source, binding::sourceKey, sourceKey, binding::varTarget, get source, binding::defaultValue] should have the same contents.
|
||||||
test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: unexpected error type: Test262: This statement should not be evaluated.
|
|
||||||
test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: strict mode: unexpected error type: Test262: This statement should not be evaluated.
|
|
||||||
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10: TypeError: $DONE() not called
|
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10: TypeError: $DONE() not called
|
||||||
test262/test/language/statements/with/get-binding-value-call-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.
|
test262/test/language/statements/with/get-binding-value-call-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.
|
||||||
test262/test/language/statements/with/get-binding-value-idref-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.
|
test262/test/language/statements/with/get-binding-value-idref-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user