Skip to content

Commit

Permalink
fix rest parameters in arrow functions containing wrong arguments ref…
Browse files Browse the repository at this point in the history
…erence - fixes #11
  • Loading branch information
sebmck committed Oct 31, 2014
1 parent ecedc23 commit 6696d5f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/6to5/transformers/_alias-functions.js
Expand Up @@ -35,6 +35,8 @@ var go = function (getBody, node, file) {
}
}

if (node._ignoreAliasFunctions) return;

var getId;

if (node.type === "Identifier" && node.name === "arguments") {
Expand Down
9 changes: 7 additions & 2 deletions lib/6to5/transformers/rest-parameters.js
Expand Up @@ -11,9 +11,14 @@ exports.Function = function (node, parent, file) {
if (node.params.length) templateName += "-arg";

util.ensureBlock(node);
node.body.body.unshift(util.template(templateName, {

var template = util.template(templateName, {
SLICE_KEY: file.addDeclaration("slice"),
VARIABLE_NAME: rest,
SLICE_ARG: b.literal(node.params.length)
}));
});

template.declarations[0].init.arguments[0]._ignoreAliasFunctions = true;

node.body.body.unshift(template);
};
@@ -0,0 +1,3 @@
var concat = (...arrs) => {

};
@@ -0,0 +1,5 @@
"use strict";
var _slice = Array.prototype.slice;
var concat = function () {
var arrs = _slice.call(arguments);
};

1 comment on commit 6696d5f

@sebmck
Copy link
Contributor Author

@sebmck sebmck commented on 6696d5f Oct 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant #111

Please sign in to comment.