- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases - This creates snapshot tests using the pretty printer for all of them - If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
21 lines
660 B
JavaScript
21 lines
660 B
JavaScript
/* @flow */
|
|
var a = [];
|
|
for (var i = 0; i < 10; ++i) {
|
|
if (i % 2 == 0) { a[i] = 0; }
|
|
else { a[i] = ''; };
|
|
}
|
|
|
|
// `i` never gets a lower bound, so the array access is stalled until the
|
|
// function is called.
|
|
function foo(i): string { return a[i]; }
|
|
|
|
// here, because we call `bar`, we the array access constraint is discharged and
|
|
// we realize a type error.
|
|
function bar(i): string { return a[i]; }
|
|
bar(0);
|
|
|
|
// annotations suffice to unblock the access constraint as well, so only
|
|
// uncalled internal functions will not find a type error, which is acceptable
|
|
// behavior as such functions are dead code.
|
|
function baz(i:number): string { return a[i]; }
|