fix error with capturing locals for a foreach using a ref
commitb2265367bb2b985b800599134515a4c494fbe94f
authorVishnu Iyengar <vsi@fb.com>
Wed, 12 Nov 2014 06:04:56 +0000 (11 22:04 -0800)
committerhhvm-bot <hhvm-bot@fb.com>
Wed, 12 Nov 2014 06:30:38 +0000 (11 22:30 -0800)
tree60864b24c5e979bca3a961ec6ea700d3db58e509
parent71ff9965ddcd8c629f36b2ebbd7b6aff07b1f3d9
fix error with capturing locals for a foreach using a ref

Summary: a foreach expression can introduce a new local variable as a reference.
GetLocals during naming was not checking for this.
Fixed this by creating a separate GetLocals for foreach that also allows a ref (a ref is not a
valid lvalue anywhere else).

Reviewed By: @jwatzman

Differential Revision: D1674885

Signature: t1:1674885:1415757288:975a8b74a7c6ecef2f52da891c4e2530116738db
hphp/hack/src/naming/naming.ml
hphp/hack/src/naming/naming_ast_helpers.ml
hphp/hack/test/typecheck/foreach_ref.php [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_ref.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_ref2.php [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_ref2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_ref3.php [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_ref3.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_ref4.php [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_ref4.php.exp [new file with mode: 0644]