diff --git a/src/babel/traversal/scope/index.js b/src/babel/traversal/scope/index.js index 158c85388a..646666738c 100644 --- a/src/babel/traversal/scope/index.js +++ b/src/babel/traversal/scope/index.js @@ -146,7 +146,7 @@ export default class Scope { } var cached = path.getData("scope"); - if (cached && cached.parent === parent) { + if (cached && cached.parent === parent && cached.block === path.node) { return cached; } else { path.setData("scope", this); diff --git a/test/core/fixtures/transformation/es6.classes/constructor/actual.js b/test/core/fixtures/transformation/es6.classes/constructor/actual.js index c968e6c108..33c274123a 100644 --- a/test/core/fixtures/transformation/es6.classes/constructor/actual.js +++ b/test/core/fixtures/transformation/es6.classes/constructor/actual.js @@ -10,3 +10,12 @@ class Foo extends Bar { this.state = "test"; } } + +class ConstructorScoping { + constructor(){ + let bar; + { + let bar; + } + } +} diff --git a/test/core/fixtures/transformation/es6.classes/constructor/expected.js b/test/core/fixtures/transformation/es6.classes/constructor/expected.js index 7169ce082f..9aefa96a1c 100644 --- a/test/core/fixtures/transformation/es6.classes/constructor/expected.js +++ b/test/core/fixtures/transformation/es6.classes/constructor/expected.js @@ -16,4 +16,13 @@ var Foo = (function (_Bar) { babelHelpers.inherits(Foo, _Bar); return Foo; -})(Bar); \ No newline at end of file +})(Bar); + +var ConstructorScoping = function ConstructorScoping() { + babelHelpers.classCallCheck(this, ConstructorScoping); + + var bar = undefined; + { + var _bar = undefined; + } +};