Mutable collection assignment support
[hiphop-php.git] / hphp / hack / test / ifc / check / mut_array_control_flow.php
blobdb3cd0a5ec922fe63fe32afc3744f1af104ef533
1 <?hh
3 class C {
4 <<__InferFlows>>
5 public function __construct(
6 <<__Policied("I")>>
7 public int $i,
8 <<__Policied("J")>>
9 public int $j,
10 ) {}
13 <<__InferFlows>>
14 function ok_vector_ix(C $c, Vector<int> $vector): void {
15 $vector[] = $c->i; // Force lump of vector to be I
17 $c->j = 0; // OK because vector append does not raise an exception
20 <<__InferFlows>>
21 function ok_map_extend(C $c, Map<string,int> $map): void {
22 $map['hello'] = $c->i; // Force lump of vector to be I
24 $c->j = 0; // OK because map extension does not raise an exception
27 <<__InferFlows>>
28 function leak_via_exn(C $c, Vector<int> $vector): void {
29 $vector[0] = $c->i; // Force lump of vector to be I
31 // There is a flow from PC which is governed by length of vector due to the
32 // conditional exception. The length is governed by the lump policy.
33 $c->j = 0; // I flows into J