Merge pull request #3171 from babel/inference-recursion
Inference recursion
This commit is contained in:
commit
16ae7c2d9a
57
packages/babel-core/test/fixtures/plugins/inference-recursion/exec.js
vendored
Normal file
57
packages/babel-core/test/fixtures/plugins/inference-recursion/exec.js
vendored
Normal 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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user