diff --git a/lib/6to5/transformation/file.js b/lib/6to5/transformation/file.js index 6dfdfe2602..127e047521 100644 --- a/lib/6to5/transformation/file.js +++ b/lib/6to5/transformation/file.js @@ -460,7 +460,7 @@ File.prototype.generateUid = function (name, scope) { File.prototype.generateUidIdentifier = function (name, scope) { scope = scope || this.scope; var id = t.identifier(this.generateUid(name, scope)); - scope.addDeclarationToFunctionScope("var", id); + scope.addBindingToFunctionScope("var", id); return id; }; diff --git a/lib/6to5/transformation/transformers/es6/constants.js b/lib/6to5/transformation/transformers/es6/constants.js index db281767dd..ce70395e9b 100644 --- a/lib/6to5/transformation/transformers/es6/constants.js +++ b/lib/6to5/transformation/transformers/es6/constants.js @@ -37,7 +37,7 @@ var visitor = { exports.Scope = function (node, parent, scope, file) { scope.traverse(node, visitor, { - constants: scope.getAllDeclarationsOfKind("const"), + constants: scope.getAllBindingsOfKind("const"), file: file }); }; diff --git a/lib/6to5/traversal/scope.js b/lib/6to5/traversal/scope.js index 3bbac0dc54..5d61ec00ec 100644 --- a/lib/6to5/traversal/scope.js +++ b/lib/6to5/traversal/scope.js @@ -250,7 +250,7 @@ var programReferenceVisitor = { var blockVariableVisitor = { enter: function (node, parent, scope, state) { if (t.isBlockScoped(node)) { - state.register(node); + state.register(node, null, "let"); } else if (t.isScope(node)) { this.skip(); } @@ -298,7 +298,7 @@ Scope.prototype.crawl = function () { if (t.isLoop(block)) { for (i = 0; i < t.FOR_INIT_KEYS.length; i++) { var node = block[t.FOR_INIT_KEYS[i]]; - if (t.isBlockScoped(node)) this.register(node, false, true); + if (t.isBlockScoped(node)) this.register(node, false, "let"); } if (t.isBlockStatement(block.body)) { @@ -310,7 +310,7 @@ Scope.prototype.crawl = function () { if (t.isFunctionExpression(block) && block.id) { if (!t.isProperty(this.parentBlock, { method: true })) { - this.register(block.id); + this.register(block.id, null, "var"); } } @@ -318,7 +318,7 @@ Scope.prototype.crawl = function () { if (t.isFunction(block)) { for (i = 0; i < block.params.length; i++) { - this.register(block.params[i]); + this.register(block.params[i], null, "var"); } this.traverse(block.body, blockVariableVisitor, this); } @@ -332,13 +332,13 @@ Scope.prototype.crawl = function () { // CatchClause - param if (t.isCatchClause(block)) { - this.register(block.param); + this.register(block.param, null, "let"); } // ComprehensionExpression - blocks if (t.isComprehensionExpression(block)) { - this.register(block); + this.register(block, null, "let"); } // Program, Function - var variables @@ -391,7 +391,7 @@ Scope.prototype.push = function (opts) { * @param {Object} node */ -Scope.prototype.addDeclarationToFunctionScope = function (kind, node) { +Scope.prototype.addBindingToFunctionScope = function (kind, node) { var scope = this.getFunctionParent(); var ids = t.getBindingIdentifiers(node); @@ -441,7 +441,7 @@ Scope.prototype.getAllBindings = function () { * @returns {Object} */ -Scope.prototype.getAllDeclarationsOfKind = function (kind) { +Scope.prototype.getAllBindingsOfKind = function (kind) { var ids = object(); var scope = this;