Inference recursion bug
This commit is contained in:
parent
59f5e7f218
commit
12fac9cadf
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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user