From b518394a3f3ca87cf9fcab25989fbff1978e3311 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Mon, 6 Jul 2015 20:52:58 -0700 Subject: [PATCH] Only special-case for..on/of declaration hoisting - fixes #1929 --- src/babel/transformation/modules/system.js | 3 +-- .../es6.modules-system/hoist-function-exports/actual.js | 2 ++ .../es6.modules-system/hoist-function-exports/expected.js | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/babel/transformation/modules/system.js b/src/babel/transformation/modules/system.js index 7223c4f9ba..83813e670f 100644 --- a/src/babel/transformation/modules/system.js +++ b/src/babel/transformation/modules/system.js @@ -33,8 +33,7 @@ var hoistVariablesVisitor = { } // for (var i in test) - // for (var i = 0;;) - if (t.isFor(parent) && (parent.left === node || parent.init === node)) { + if (t.isFor(parent) && parent.left === node) { return node.declarations[0].id; } diff --git a/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/actual.js b/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/actual.js index 64ebb67787..86954f1cea 100644 --- a/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/actual.js +++ b/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/actual.js @@ -8,6 +8,8 @@ export var p = 5; for (var a in b) ; +for (var i = 0, j = 0;;) ; + export var isOdd = (function (isEven) { return function (n) { return !isEven(n); diff --git a/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/expected.js b/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/expected.js index 6e5381d373..4412e7284a 100644 --- a/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/expected.js +++ b/test/core/fixtures/transformation/es6.modules-system/hoist-function-exports/expected.js @@ -1,7 +1,7 @@ System.register(["./evens"], function (_export) { "use strict"; - var isEven, p, a, isOdd; + var isEven, p, a, i, j, isOdd; _export("nextOdd", nextOdd); @@ -20,6 +20,8 @@ System.register(["./evens"], function (_export) { for (a in b); + for (i = 0, j = 0;;); + isOdd = (function (isEven) { return function (n) { return !isEven(n);