Requeueing sometimes has wrong scope (#6351)

This prevents a requeued path from inheriting a totally wrong scope later on. I can't find exactly where this is happening, but either way a path should only inherit scope from it's ancestors.
This commit is contained in:
Justin Ridgewell 2017-10-02 15:26:10 -04:00 committed by GitHub
parent 977c72250a
commit 73fba55c9f
4 changed files with 50 additions and 9 deletions

View File

@ -0,0 +1,10 @@
import { copy } from './copyPaste';
class Thing {
handleCopySomething() {
copy();
}
completelyUnrelated(copy = 123) {
}
}

View File

@ -0,0 +1,31 @@
"use strict";
var _copyPaste = require("./copyPaste");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Thing =
/*#__PURE__*/
function () {
function Thing() {
_classCallCheck(this, Thing);
}
_createClass(Thing, [{
key: "handleCopySomething",
value: function handleCopySomething() {
(0, _copyPaste.copy)();
}
}, {
key: "completelyUnrelated",
value: function completelyUnrelated() {
var copy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 123;
}
}]);
return Thing;
}();

View File

@ -0,0 +1,3 @@
{
"plugins": ["transform-es2015-parameters", "transform-es2015-classes", "transform-es2015-modules-commonjs", "transform-es2015-block-scoping"]
}

View File

@ -95,16 +95,13 @@ export function stop() {
export function setScope() {
if (this.opts && this.opts.noScope) return;
let target = this.context && this.context.scope;
let path = this.parentPath;
let target;
while (path && !target) {
if (path.opts && path.opts.noScope) return;
if (!target) {
let path = this.parentPath;
while (path && !target) {
if (path.opts && path.opts.noScope) return;
target = path.scope;
path = path.parentPath;
}
target = path.scope;
path = path.parentPath;
}
this.scope = this.getScope(target);