global statement removal: hphp/test [7/x]
[hiphop-php.git] / hphp / test / quick / lambda4.php
blob3ef56f1d6ef218e966d9f9efd5a223ed93efb1a6
1 <?hh
3 function function_scope() {
4 // Shouldn't try to capture $k
5 $bar = () ==> {
6 foreach (array(1,2,3,4) as $k) {
7 var_dump($k);
9 };
10 $bar();
12 // Also shouldn't capture $x, $y:
13 $baz = () ==> {
14 $x = 12;
15 $y = 13;
16 echo $x . $y . "\n";
18 $baz();
20 // But this will capture $z, however it will be uninit at closure
21 // allocation time (in non-repo mode). It will give a warning
22 // closure call time. It will also give an ahead-of-type error
23 // from hh about $z not being defined.
24 $quux = () ==> { var_dump(isset($z)); };
25 $z = "function scope is weird\n";
26 echo "z in parent is now: $z\n";
27 $quux(); // print NULL
30 function_scope();