Error on self::class on non final classes
[hiphop-php.git] / hphp / hack / test / typecheck / not_trivial_strict_eq.php
blob57a6ac4e7741d2dc3eb69d9eb0f554c341ac8162
1 <?hh // partial
2 /**
3 * Copyright (c) 2014, Facebook, Inc.
4 * All rights reserved.
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the "hack" directory of this source tree.
12 function f() {}
14 function getArr(): array<int> { return varray[]; }
16 function g(): void {
17 $a = getArr();
18 $b = varray[];
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;