Check for void/noreturn in conditionals
[hiphop-php.git] / hphp / hack / test / typecheck / finally_basic.php
blobb5417f8e9793d349f0ed63d90c6169fdfa942661
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 finally_basic(): int {
13 $a = 23;
14 try {
15 $a = 456;
16 } catch (NonTerminalException $e) {
17 $a = 28;
18 } catch (SomeException $e) {
19 return $a = 23;
20 } catch (Exception $e) {
21 return $a = 456;
22 } finally {
23 echo $a;
24 $b = 'quack'; // should be fine (!)
25 echo $b;
27 return $a;
30 function do_something(): void {
31 throw new Exception('something like throwing :)');
34 class TestInit {
35 private int $foo;
37 public function __construct() {
38 try {
39 do_something();
40 $this->foo = 26;
41 } finally {
42 $this->foo = 25;