From dc6a862beca9e5394f36e2f86ca8ebfc5bef473d Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 17 Jan 2015 10:23:53 +1100 Subject: [PATCH] better clarification of rest parameter size construction comment --- .../transformation/transformers/es6-rest-parameters.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/6to5/transformation/transformers/es6-rest-parameters.js b/lib/6to5/transformation/transformers/es6-rest-parameters.js index 68dfdd0ae8..bf6546a9c1 100644 --- a/lib/6to5/transformation/transformers/es6-rest-parameters.js +++ b/lib/6to5/transformation/transformers/es6-rest-parameters.js @@ -27,9 +27,11 @@ exports.Function = function (node, parent, file) { arrKey = t.binaryExpression("-", key, start); // 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 + // going to store all the rest parameters + // + // we need to add a check to avoid constructing the array + // with <1 if there are less arguments than params as it'll + // cause an error arrLen = t.conditionalExpression( t.binaryExpression(">", len, start), t.binaryExpression("-", len, start),