add ambiguous rest parameters comment

This commit is contained in:
Sebastian McKenzie 2015-01-16 00:50:38 +11:00
parent e512264be7
commit d7810cac08

View File

@ -19,15 +19,17 @@ exports.Function = function (node, parent, file) {
var len = file.generateUidIdentifier("len");
var arrKey = key;
var arrLen = len;
if (node.params.length) {
// this method has additional params, so we need to subtract
// the index of the current argument position from the
// position in the array that we want to populate
arrKey = t.binaryExpression("-", key, start);
}
var arrLen = len;
if (node.params.length) {
// we need to work out the size of the array that we're
// going to store all the rest parameters in, if there
// are less arguments than params then the array can be
// constructed with <1 which will cause an error
arrLen = t.conditionalExpression(
t.binaryExpression(">", len, start),
t.binaryExpression("-", len, start),