Ensure that we push and pop evenly so things don't fail to queue - fixes T7199

This commit is contained in:
Logan Smyth 2016-03-12 12:28:22 -08:00
parent 5373733b8d
commit b1c50b01f2
4 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,2 @@
import foo from 'foo';
const [x] = bar;

View File

@ -0,0 +1,15 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _foo = require('foo');
var _foo2 = _interopRequireDefault(_foo);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _bar = bar;
var _bar2 = _slicedToArray(_bar, 1);
const x = _bar2[0];

View File

@ -0,0 +1,8 @@
{
"plugins": [
"transform-es2015-destructuring",
"transform-es2015-modules-commonjs",
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
]
}

View File

@ -103,7 +103,13 @@ export default class TraversalContext {
// visit the queue
for (let path of queue) {
path.resync();
path.pushContext(this);
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this){
// The context might already have been pushed when this path was inserted and queued.
// If we always re-pushed here, we could get duplicates and risk leaving contexts
// on the stack after the traversal has completed, which could break things.
path.pushContext(this);
}
// this path no longer belongs to the tree
if (path.key === null) continue;