better arguments aliasing for arrow functions, add it to block binding - fixes #52

This commit is contained in:
Sebastian McKenzie
2014-10-12 15:32:40 +11:00
parent 6a392be338
commit 73c491ecb4
7 changed files with 111 additions and 28 deletions

View File

@@ -1,10 +1,10 @@
function outer() {
function one() {
var inner = () => arguments;
return [].slice.call(inner());
}
console.log(outer(1, 2));
one(1, 2);
function outer() {
function two() {
var inner = () => arguments;
var another = function () {
@@ -13,4 +13,22 @@ function outer() {
return [].slice.call(inner());
}
console.log(outer(1, 2));
two(1, 2);
function three() {
var fn = () => arguments[0] + "bar";
return fn();
}
three("foo");
function four() {
var fn = () => arguments[0].foo + "bar";
return fn();
}
four({ foo: "foo" });
function five(obj) {
var fn = () => obj.arguments[0].foo + "bar";
return fn();
}
five({ arguments: ["foo"] });

View File

@@ -1,11 +1,11 @@
function outer() {
function one() {
var _arguments = arguments;
var inner = function () { return _arguments; };
return [].slice.call(inner());
}
console.log(outer(1, 2));
one(1, 2);
function outer() {
function two() {
var _arguments2 = arguments;
var inner = function () { return _arguments2; };
@@ -16,4 +16,30 @@ function outer() {
return [].slice.call(inner());
}
console.log(outer(1, 2));
two(1, 2);
function three() {
var _arguments4 = arguments;
var fn = function () {
return _arguments4[0] + "bar";
};
return fn();
}
three("foo");
function four() {
var _arguments5 = arguments;
var fn = function () {
return _arguments5[0].foo + "bar";
};
return fn();
}
four({ foo: "foo" });
function five(obj) {
var fn = function () {
return obj.arguments[0].foo + "bar";
};
return fn();
}
five({ arguments: ["foo"] });

View File

@@ -0,0 +1,6 @@
(function () {
if (true) {
let a = arguments[0];
console.log(a);
}
})(1);

View File

@@ -0,0 +1,9 @@
(function () {
if (true) {
var _arguments = arguments;
(function () {
var a = _arguments[0];
console.log(a);
})();
}
})(1);