Check for void/noreturn in conditionals
[hiphop-php.git] / hphp / hack / test / typecheck / not_trivial_strict_eq.php
blobf2f2f3a64670161a9e38590e605158656fd17d07
1 <?hh
2 /**
3 * Copyright (c) 2014, Facebook, Inc.
4 * All rights reserved.
6 * This source code is licensed under the BSD-style license found in the
7 * LICENSE file in the "hack" directory of this source tree. An additional grant
8 * of patent rights can be found in the PATENTS file in the same directory.
12 function f() {}
14 function getArr(): array<int> { return array(); }
16 function g(): void {
17 $a = getArr();
18 $b = array();
19 $idx = f();
21 // not entirely sure why, but this if statement is needed to trigger an error
22 // in a naive implementation of the trivial strict equality check
23 if (true) {
26 /* This is not a trivial strict equality check [4118]: $idx will be inferred
27 * to be an int inside the if block, but right now it is still TAny. This
28 * test verifies that we are doing the trivial strict equality test at the
29 * right point */
30 if ($idx !== false) {
31 $b[] = $a[$idx];
35 function h(?int $a, ?string $b): bool {
36 // Not a trivial comparison since both $a and $b can be null
37 return $a === $b;