No error on use of `unsafe_cast`
[hiphop-php.git] / hphp / hack / test / typecheck / pipe_ternary_nested_ternary.php
blob4b68e03162c91b92db18147e80e23c7a8f8b9766
1 <?hh // strict
3 // This test cases checks for a previous bug that
4 // $$ loses its typing information in a ternary
5 // expression. In this bug case the $$ will have Tany,
6 // hence passing both checks. Had it been properly typed,
7 // this will report a type error at expect_string
8 function expect_fail(bool $b1, bool $b2): void {
9 $broken = 1
10 |> ($b1 ? ($b2 ? $$ : $$) : ($b2 ? $$ : $$));
11 expect_int($broken);
12 expect_string($broken);
15 function int2string(int $i): string {
16 return '42';
18 function expect_int(int $i): void {}
19 function expect_string(string $s): void {}