diff --git a/lib/6to5/transformation/transformers/es6/for-of.js b/lib/6to5/transformation/transformers/es6/for-of.js index 46a4b11155..0312e7f270 100644 --- a/lib/6to5/transformation/transformers/es6/for-of.js +++ b/lib/6to5/transformation/transformers/es6/for-of.js @@ -27,7 +27,8 @@ exports.ForOfStatement = function (node, parent, scope, file) { // push the rest of the original loop body onto our new body block.body = block.body.concat(node.body.body); - block._declarations = node.body._declarations; + + t.inherits(loop, node); // todo: find out why this is necessary? #538 loop._scopeInfo = node._scopeInfo; diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index fb406b3fd9..12d253e197 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -6,6 +6,7 @@ var isString = require("lodash/lang/isString"); var compact = require("lodash/array/compact"); var esutils = require("esutils"); var object = require("../helpers/object"); +var merge = require("lodash/object/merge"); var Node = require("./node"); var each = require("lodash/collection/each"); var uniq = require("lodash/array/uniq"); @@ -690,10 +691,12 @@ t.inheritsComments = function (child, parent) { */ t.inherits = function (child, parent) { - child.range = parent.range; - child.start = parent.start; - child.loc = parent.loc; - child.end = parent.end; + child._declarations = parent._declarations; + child._scopeInfo = parent._scopeInfo; + child.range = parent.range; + child.start = parent.start; + child.loc = parent.loc; + child.end = parent.end; t.inheritsComments(child, parent); return child; };