Files
test-repo/tests/flow/locals/lex.js
T
Christopher Chedeau 3375cfe605 Move tests around (#454)
* new_tests

* move_all_clobbered_tests

* remove all the tests that no longer exist

* re-run flow tests

* Move all the flow tests to tests/flow and prettier to tests/

* Move prettier tests to their own folders

* Add jsfmt files

* run prettier snapshot tests
2017-01-24 14:35:37 -08:00

61 lines
1.1 KiB
JavaScript

function switch_scope(x: mixed) {
let a = "";
let b = "";
switch (x) {
case "foo":
let a;
a = 0; // doesn't add lower bound to outer a
b = 0;
}
(a : string); // OK
(b : string); // error: number ~> string
}
function try_scope_finally() {
let a;
let b;
try {
a = "";
b = "";
} finally {
let a;
a = 0; // doesn't add lower bound to outer a
b = 0;
}
(a : string); // ok
(b : string); // error: number ~> string
}
function for_scope() {
let a = "";
let b = "";
for (let a;;) {
a = 0; // doesn't add lower bound to outer a
b = 0;
}
(a : string);
(b : string); // error: number ~> string
}
function for_in_scope(o: Object) {
let a = 0;
let b = 0;
for (let a in o) {
a = ""; // doesn't add lower bound to outer a
b = "";
}
(a : number);
(b : number); // error: string ~> number
}
function for_of_scope(xs: number[]) {
let a = "";
let b = "";
for (let a of xs) {
a = 0; // doesn't add lower bound to outer a
b = 0;
}
(a : string);
(b : string); // error: number ~> string
}