fix rest parameters in arrow functions containing wrong arguments reference - fixes #11

This commit is contained in:
Sebastian McKenzie
2014-10-31 11:42:09 +11:00
parent ecedc23892
commit 6696d5fcf4
4 changed files with 17 additions and 2 deletions

View File

@@ -35,6 +35,8 @@ var go = function (getBody, node, file) {
}
}
if (node._ignoreAliasFunctions) return;
var getId;
if (node.type === "Identifier" && node.name === "arguments") {

View File

@@ -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);
};