parse destructuring under strict mode correctly (#4429)
This commit is contained in:
15
lib/parse.js
15
lib/parse.js
@@ -1551,8 +1551,7 @@ function parse($TEXT, options) {
|
||||
next();
|
||||
return "" + tmp.value;
|
||||
case "punc":
|
||||
if (tmp.value != "[") unexpected();
|
||||
next();
|
||||
expect("[");
|
||||
var key = maybe_assign();
|
||||
expect("]");
|
||||
return key;
|
||||
@@ -1616,21 +1615,21 @@ function parse($TEXT, options) {
|
||||
// allow trailing comma
|
||||
if (!options.strict && is("punc", "}")) break;
|
||||
var key_start = S.token;
|
||||
var key = as_property_key();
|
||||
if (!is("punc", ":") && key_start.type == "name") {
|
||||
if (is("punc", "[") || is_token(peek(), "punc", ":")) {
|
||||
var key = as_property_key();
|
||||
expect(":");
|
||||
a.push(new AST_DestructuredKeyVal({
|
||||
start: key_start,
|
||||
key: key,
|
||||
value: _make_symbol(type, key_start),
|
||||
value: maybe_destructured(type),
|
||||
end: prev(),
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
expect(":");
|
||||
a.push(new AST_DestructuredKeyVal({
|
||||
start: key_start,
|
||||
key: key,
|
||||
value: maybe_destructured(type),
|
||||
key: key_start.value,
|
||||
value: as_symbol(type),
|
||||
end: prev(),
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user