diff --git a/src/babel/transformation/file/index.js b/src/babel/transformation/file/index.js
index ed2ea6d4f8..eaa53be048 100644
--- a/src/babel/transformation/file/index.js
+++ b/src/babel/transformation/file/index.js
@@ -44,6 +44,7 @@ export default class File {
this.usedHelpers = {};
this.dynamicData = {};
this.data = {};
+ this.uids = {};
this.lastStatements = [];
this.log = new Logger(this, opts.filename || "unknown");
diff --git a/src/babel/traversal/scope.js b/src/babel/traversal/scope.js
index e090462403..99056e5bab 100644
--- a/src/babel/traversal/scope.js
+++ b/src/babel/traversal/scope.js
@@ -135,7 +135,7 @@ export default class Scope {
uid = this._generateUid(name, i);
i++;
} while (this.hasBinding(uid) || this.hasGlobal(uid) || this.hasUid(uid));
- this.getFunctionParent().uids[uid] = true;
+ this.file.uids[uid] = true;
return uid;
}
@@ -152,7 +152,7 @@ export default class Scope {
hasUid(name): boolean {
var scope = this;
do {
- if (scope.uids[name]) return true;
+ if (scope.file.uids[name]) return true;
scope = scope.parent;
} while (scope);
return false;
@@ -434,8 +434,7 @@ export default class Scope {
info = this.block._scopeInfo = {
bindings: object(),
- globals: object(),
- uids: object()
+ globals: object()
};
extend(this, info);
@@ -658,7 +657,7 @@ export default class Scope {
if (!name) return false;
if (this.hasOwnBinding(name)) return true;
if (this.parentHasBinding(name)) return true;
- if (this.uids[name]) return true;
+ if (this.file.uids[name]) return true;
if (includes(Scope.globals, name)) return true;
if (includes(Scope.contextVariables, name)) return true;
return false;
diff --git a/test/core/fixtures/transformation/es6.arrow-functions/arguments/expected.js b/test/core/fixtures/transformation/es6.arrow-functions/arguments/expected.js
index eac62b4a0e..b8104fab4d 100644
--- a/test/core/fixtures/transformation/es6.arrow-functions/arguments/expected.js
+++ b/test/core/fixtures/transformation/es6.arrow-functions/arguments/expected.js
@@ -11,17 +11,17 @@ function one() {
one(1, 2);
function two() {
- var _arguments = arguments;
+ var _arguments2 = arguments;
var inner = function inner() {
- return _arguments;
+ return _arguments2;
};
var another = function another() {
- var _arguments2 = arguments;
+ var _arguments3 = arguments;
var inner2 = function inner2() {
- return _arguments2;
+ return _arguments3;
};
};
@@ -30,20 +30,20 @@ function two() {
two(1, 2);
function three() {
- var _arguments = arguments;
+ var _arguments4 = arguments;
var fn = function fn() {
- return _arguments[0] + "bar";
+ return _arguments4[0] + "bar";
};
return fn();
}
three("foo");
function four() {
- var _arguments = arguments;
+ var _arguments5 = arguments;
var fn = function fn() {
- return _arguments[0].foo + "bar";
+ return _arguments5[0].foo + "bar";
};
return fn();
}
@@ -66,4 +66,4 @@ function six(obj) {
};
return fn();
}
-six();
+six();
\ No newline at end of file
diff --git a/test/core/fixtures/transformation/es6.block-scoping/for-break-continue-return/expected.js b/test/core/fixtures/transformation/es6.block-scoping/for-break-continue-return/expected.js
index 57da26353c..b67076795a 100644
--- a/test/core/fixtures/transformation/es6.block-scoping/for-break-continue-return/expected.js
+++ b/test/core/fixtures/transformation/es6.block-scoping/for-break-continue-return/expected.js
@@ -16,7 +16,7 @@
}
};
- _loop: for (var i in nums) {
+ _loop2: for (var i in nums) {
var _ret = _loop(i);
switch (_ret) {
@@ -24,7 +24,7 @@
continue;
case "break":
- break _loop;
+ break _loop2;
default:
if (typeof _ret === "object") return _ret.v;
diff --git a/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js b/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js
index 60f3c20e81..fa1b8ef7ae 100644
--- a/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js
+++ b/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js
@@ -20,11 +20,11 @@ var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
Test.prototype.test = function test() {
- var _Foo$prototype$test, _Foo$prototype$test2;
+ var _Foo$prototype$test3, _Foo$prototype$test4;
_Foo.prototype.test.call(this);
- (_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(babelHelpers.slice.call(arguments)));
- (_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(babelHelpers.slice.call(arguments)));
+ (_Foo$prototype$test3 = _Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(babelHelpers.slice.call(arguments)));
+ (_Foo$prototype$test4 = _Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(babelHelpers.slice.call(arguments)));
};
Test.foo = function foo() {
diff --git a/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js b/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js
index ea5b6257f4..42672ea451 100644
--- a/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js
+++ b/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js
@@ -21,21 +21,21 @@ var Test = (function (_Foo) {
babelHelpers.createClass(Test, [{
key: "test",
value: function test() {
- var _babelHelpers$get;
+ var _babelHelpers$get3;
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).apply(this, arguments);
- (_babelHelpers$get = babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get, [this, "test"].concat(babelHelpers.slice.call(arguments)));
+ (_babelHelpers$get3 = babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get3, [this, "test"].concat(babelHelpers.slice.call(arguments)));
}
}], [{
key: "foo",
value: function foo() {
- var _babelHelpers$get;
+ var _babelHelpers$get4;
babelHelpers.get(Object.getPrototypeOf(Test), "foo", this).call(this);
babelHelpers.get(Object.getPrototypeOf(Test), "foo", this).apply(this, arguments);
- (_babelHelpers$get = babelHelpers.get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_babelHelpers$get, [this, "test"].concat(babelHelpers.slice.call(arguments)));
+ (_babelHelpers$get4 = babelHelpers.get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_babelHelpers$get4, [this, "test"].concat(babelHelpers.slice.call(arguments)));
}
}]);
return Test;
-})(Foo);
+})(Foo);
\ No newline at end of file
diff --git a/test/core/fixtures/transformation/es6.destructuring/parameters/expected.js b/test/core/fixtures/transformation/es6.destructuring/parameters/expected.js
index d88a23e959..50365469a1 100644
--- a/test/core/fixtures/transformation/es6.destructuring/parameters/expected.js
+++ b/test/core/fixtures/transformation/es6.destructuring/parameters/expected.js
@@ -9,29 +9,29 @@ function somethingAdvanced(_ref) {
var y2 = _ref$bottomRight.y;
}
-function unpackObject(_ref) {
- var title = _ref.title;
- var author = _ref.author;
+function unpackObject(_ref2) {
+ var title = _ref2.title;
+ var author = _ref2.author;
return title + " " + author;
}
console.log(unpackObject({ title: "title", author: "author" }));
-var unpackArray = function unpackArray(_ref, _ref3) {
- var _ref2 = babelHelpers.slicedToArray(_ref, 3);
-
- var a = _ref2[0];
- var b = _ref2[1];
- var c = _ref2[2];
-
+var unpackArray = function unpackArray(_ref3, _ref4) {
var _ref32 = babelHelpers.slicedToArray(_ref3, 3);
- var x = _ref32[0];
- var y = _ref32[1];
- var z = _ref32[2];
+ var a = _ref32[0];
+ var b = _ref32[1];
+ var c = _ref32[2];
+
+ var _ref42 = babelHelpers.slicedToArray(_ref4, 3);
+
+ var x = _ref42[0];
+ var y = _ref42[1];
+ var z = _ref42[2];
return a + b + c;
};
-console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3]));
+console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3]));
\ No newline at end of file
diff --git a/test/core/fixtures/transformation/es6.parameters.rest/deopt/expected.js b/test/core/fixtures/transformation/es6.parameters.rest/deopt/expected.js
index fff7c33680..eeef013489 100644
--- a/test/core/fixtures/transformation/es6.parameters.rest/deopt/expected.js
+++ b/test/core/fixtures/transformation/es6.parameters.rest/deopt/expected.js
@@ -9,8 +9,8 @@ var x = function x(foo) {
};
var y = function y(foo) {
- for (var _len = arguments.length, bar = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- bar[_key - 1] = arguments[_key];
+ for (var _len2 = arguments.length, bar = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
+ bar[_key2 - 1] = arguments[_key2];
}
var x = function z(bar) {
@@ -19,8 +19,8 @@ var y = function y(foo) {
};
var b = function b(x, y) {
- for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
- args[_key - 2] = arguments[_key];
+ for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
+ args[_key3 - 2] = arguments[_key3];
}
console.log(args[0]);
@@ -29,8 +29,8 @@ var b = function b(x, y) {
};
var z = function z(foo) {
- for (var _len = arguments.length, bar = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- bar[_key - 1] = arguments[_key];
+ for (var _len4 = arguments.length, bar = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
+ bar[_key4 - 1] = arguments[_key4];
}
var x = function x() {
@@ -39,18 +39,18 @@ var z = function z(foo) {
};
var a = function a(foo) {
- for (var _len = arguments.length, bar = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- bar[_key - 1] = arguments[_key];
+ for (var _len5 = arguments.length, bar = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
+ bar[_key5 - 1] = arguments[_key5];
}
return bar.join(",");
};
var b = function b(foo) {
- for (var _len = arguments.length, bar = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- bar[_key - 1] = arguments[_key];
+ for (var _len6 = arguments.length, bar = Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
+ bar[_key6 - 1] = arguments[_key6];
}
var join = "join";
return bar[join];
-};
+};
\ No newline at end of file
diff --git a/test/core/fixtures/transformation/es6.tail-call/try-catch/expected.js b/test/core/fixtures/transformation/es6.tail-call/try-catch/expected.js
index 5fbeb6cd4c..c3f3b9bc69 100755
--- a/test/core/fixtures/transformation/es6.tail-call/try-catch/expected.js
+++ b/test/core/fixtures/transformation/es6.tail-call/try-catch/expected.js
@@ -43,21 +43,21 @@
} finally {}
})(1000000) === "foo";
-(function f(_x) {
- var _again = true;
+(function f(_x2) {
+ var _again2 = true;
- _function: while (_again) {
- _again = false;
- var n = _x;
+ _function2: while (_again2) {
+ _again2 = false;
+ var n = _x2;
if (n <= 0) {
return "foo";
}
try {} finally {
- _x = n - 1;
- _again = true;
- continue _function;
+ _x2 = n - 1;
+ _again2 = true;
+ continue _function2;
}
}
})(1000000) === "foo";
\ No newline at end of file
diff --git a/test/core/fixtures/transformation/optimisation.react.constant-elements/function-parameter/expected.js b/test/core/fixtures/transformation/optimisation.react.constant-elements/function-parameter/expected.js
index 6f4e3c43ec..73d39be764 100644
--- a/test/core/fixtures/transformation/optimisation.react.constant-elements/function-parameter/expected.js
+++ b/test/core/fixtures/transformation/optimisation.react.constant-elements/function-parameter/expected.js
@@ -11,9 +11,9 @@ function render(text) {
var Foo2 = require("Foo");
function createComponent(text) {
- var _ref =