Only last parameter between parentheses can have spread

This commit is contained in:
Anthony Van de Gejuchte
2016-06-12 22:40:07 +02:00
committed by Richard van Velzen
parent f9cab7ad61
commit 6b03b800b3
5 changed files with 170 additions and 0 deletions

View File

@@ -1163,12 +1163,16 @@ function parse($TEXT, options) {
while (!is("punc", ")")) {
if (first) first = false; else expect(",");
if (is("expand", "...")) {
var spread_token = S.token;
next();
a.push(new AST_Expansion({
start: prev(),
expression: as_symbol(AST_SymbolFunarg),
end: S.token,
}));
if (!is("punc", ")")) {
unexpected(spread_token);
}
} else {
a.push(expression(false));
}