extend trailing comma support (#4334)
This commit is contained in:
17
lib/parse.js
17
lib/parse.js
@@ -1053,12 +1053,9 @@ function parse($TEXT, options) {
|
||||
if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
|
||||
unexpected(prev());
|
||||
expect("(");
|
||||
var argnames = [];
|
||||
for (var first = true; !is("punc", ")");) {
|
||||
if (first) first = false; else expect(",");
|
||||
argnames.push(maybe_destructured(AST_SymbolFunarg));
|
||||
}
|
||||
next();
|
||||
var argnames = expr_list(")", !options.strict, false, function() {
|
||||
return maybe_destructured(AST_SymbolFunarg);
|
||||
});
|
||||
var loop = S.in_loop;
|
||||
var labels = S.labels;
|
||||
++S.in_function;
|
||||
@@ -1233,7 +1230,7 @@ function parse($TEXT, options) {
|
||||
var newexp = expr_atom(false), args;
|
||||
if (is("punc", "(")) {
|
||||
next();
|
||||
args = expr_list(")");
|
||||
args = expr_list(")", !options.strict);
|
||||
} else {
|
||||
args = [];
|
||||
}
|
||||
@@ -1351,9 +1348,9 @@ function parse($TEXT, options) {
|
||||
while (!is("punc", closing)) {
|
||||
if (first) first = false; else expect(",");
|
||||
if (allow_trailing_comma && is("punc", closing)) break;
|
||||
if (is("punc", ",") && allow_empty) {
|
||||
if (allow_empty && is("punc", ",")) {
|
||||
a.push(new AST_Hole({ start: S.token, end: S.token }));
|
||||
} else if (is("operator", "...") && parser === expression) {
|
||||
} else if (parser === expression && is("operator", "...")) {
|
||||
a.push(new AST_Spread({
|
||||
start: S.token,
|
||||
expression: (next(), parser()),
|
||||
@@ -1593,7 +1590,7 @@ function parse($TEXT, options) {
|
||||
var call = new AST_Call({
|
||||
start : start,
|
||||
expression : expr,
|
||||
args : expr_list(")"),
|
||||
args : expr_list(")", !options.strict),
|
||||
end : prev()
|
||||
});
|
||||
mark_pure(call);
|
||||
|
||||
Reference in New Issue
Block a user