Merge pull request #3171 from babel/inference-recursion

Inference recursion
This commit is contained in:
Sebastian McKenzie 2015-12-17 14:44:29 +00:00
commit 16ae7c2d9a
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,57 @@
var code = (function() {
var kind;
function readObj() {
expect('{');
if (!skip('}')) {
do {
expect('String');
expect(':');
readVal();
} while (skip(','));
expect('}');
}
}
function expect(str) {
if (kind === str) {
return lex();
}
throw syntaxError('Expected ' + str + ' but got ' + string.slice(start, end) + '.');
}
function readArr() {
expect('[');
if (!skip(']')) {
do {
readVal();
} while (skip(','));
expect(']');
}
}
function readVal() {
switch (kind) {
case '[':
return readArr();
case '{':
return readObj();
case 'String':
return lex();
default:
return expect('Value');
}
}
}).toString().split('\n').slice(1, -1).join('\n');
transform(code, {
plugins: function (b) {
var t = b.types;
return {
visitor: {
BinaryExpression: function(path) {
path.get("left").baseTypeStrictlyMatches(path.get("right"));
}
}
}
}
});

View File

@ -235,7 +235,9 @@ export function _guessExecutionStatusRelativeTo(target) {
let targetFuncParent = target.scope.getFunctionParent();
let selfFuncParent = this.scope.getFunctionParent();
if (targetFuncParent !== selfFuncParent) {
// here we check the `node` equality as sometimes we may have different paths for the
// same node due to path thrashing
if (targetFuncParent.node !== selfFuncParent.node) {
let status = this._guessExecutionStatusRelativeToDifferentFunctions(targetFuncParent);
if (status) {
return status;