-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: When a Uref is in a foreach loop, the Uref node is collapsed into an Lvar. This diff preserves the Uref node. Reviewed By: jamesjwu Differential Revision: D5554699 fbshipit-source-id: 524cf07a52017e6244378d37110ab5b5bfdc92b7
- Loading branch information
1 parent
58de2a6
commit 4cedc0e
Showing
3 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?hh | ||
function foo(): int { | ||
$arr = array(1, 2, 3); | ||
$y = 0; | ||
foreach ($arr as &$val) { | ||
$y += $val++; | ||
} | ||
var_dump($arr); | ||
return $y; | ||
} | ||
foo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[(AnnotatedAST.Fun | ||
{ AnnotatedAST.f_mode = <opaque>; | ||
f_ret = (Some (<p>, (Hprim Tint))); | ||
f_name = (<p>, "\\foo"); f_tparams = []; | ||
f_where_constraints = []; f_variadic = AnnotatedAST.FVnonVariadic; | ||
f_params = []; | ||
f_body = | ||
(AnnotatedAST.NamedBody | ||
{ AnnotatedAST.fnb_nast = | ||
[(AnnotatedAST.Expr | ||
((Some array<int>), | ||
(AnnotatedAST.Binop ((Eq None), | ||
((Some array<int>), | ||
(AnnotatedAST.Lvar (<p>, $arr))), | ||
((Some array<int>), | ||
(AnnotatedAST.Array | ||
[(AnnotatedAST.AFvalue | ||
((Some int), | ||
(AnnotatedAST.Int (<p>, "1")))); | ||
(AnnotatedAST.AFvalue | ||
((Some int), | ||
(AnnotatedAST.Int (<p>, "2")))); | ||
(AnnotatedAST.AFvalue | ||
((Some int), | ||
(AnnotatedAST.Int (<p>, "3")))) | ||
])) | ||
)))); | ||
(AnnotatedAST.Expr | ||
((Some int), | ||
(AnnotatedAST.Binop ((Eq None), | ||
((Some int), (AnnotatedAST.Lvar (<p>, $y))), | ||
((Some int), (AnnotatedAST.Int (<p>, "0"))))))); | ||
(AnnotatedAST.Foreach ( | ||
((Some array<int>), (AnnotatedAST.Lvar (<p>, $arr))), | ||
(AnnotatedAST.As_v | ||
((Some int), | ||
(AnnotatedAST.Unop (Uref, | ||
((Some int), (AnnotatedAST.Lvar (<p>, $val))) | ||
)))), | ||
[(AnnotatedAST.Expr | ||
((Some int), | ||
(AnnotatedAST.Binop ((Eq (Some Plus)), | ||
((Some int), (AnnotatedAST.Lvar (<p>, $y))), | ||
((Some int), | ||
(AnnotatedAST.Unop (Upincr, | ||
((Some int), | ||
(AnnotatedAST.Lvar (<p>, $val))) | ||
))) | ||
)))) | ||
] | ||
)); | ||
(AnnotatedAST.Expr | ||
((Some _), | ||
(AnnotatedAST.Call (Cnormal, | ||
((Some (function<...>($expression): _)), | ||
(AnnotatedAST.Id (<p>, "\\var_dump"))), | ||
[], | ||
[((Some array<int>), | ||
(AnnotatedAST.Lvar (<p>, $arr)))], | ||
[])))); | ||
(AnnotatedAST.Return (<p>, | ||
(Some ((Some int), (AnnotatedAST.Lvar (<p>, $y)))) | ||
)) | ||
]; | ||
fnb_unsafe = false }); | ||
f_fun_kind = FSync; f_user_attributes = [] }) | ||
] |