Check for void/noreturn in conditionals
[hiphop-php.git] / hphp / hack / test / typecheck / unused_awaitable19.php
blobcc7c49cca0b2666446c4ba45cae3c0537f8a39f6
1 <?hh // strict
2 // Copyright 2004-present Facebook. All Rights Reserved.
4 class C {
5 public function syncCheck(): bool {
6 return true;
8 public async function genAsyncCheck(): Awaitable<bool> {
9 return true;
11 public async function test(bool $fast_path): Awaitable<int> {
12 if ($fast_path) {
13 // This is a bool
14 $is_valid = $this->syncCheck();
15 } else {
16 // This is an Awaitable<bool> (author forgot to await)
17 $is_valid = $this->genAsyncCheck();
20 // This is a truthy check on (bool | Awaitable<bool>) which is sketchy
21 if ($is_valid) {
22 return 2;
23 } else {
24 return 3;