Recurse into inner expressions before outer ones in readonly check
commit621269cd6a5c63255ef039c77877d6383ec04804
authorJames Wu <jjwu@fb.com>
Mon, 13 Dec 2021 03:02:15 +0000 (12 19:02 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 13 Dec 2021 03:05:07 +0000 (12 19:05 -0800)
tree588dd602ac66c1e0759d2a79af95fe0f3894ec61
parent73ac3db0d7740f3b752ffbd7c3ce69df4e4c13f7
Recurse into inner expressions before outer ones in readonly check

Summary:
This diff handles two cases of bugs due to assignment order: in foreach, we should assign to the "as" statement on every iteration of the loop.
In general, expressions should be analyzed depth first, in that we should evaluate and update the context of inner expressions before the outer one, as that's the order of evaluation for the runtime.

Having to use `is_typechecker` everywhere is kind of gross, but necessary, and that represents the bulk of this diff.

Reviewed By: oulgen

Differential Revision: D33030063

fbshipit-source-id: 1d66824940c2e8e7ce28fece2d3c9edfdec88a85
hphp/hack/src/parser/readonly_check.rs
hphp/test/slow/readonly/assignment_orders.php [new file with mode: 0644]
hphp/test/slow/readonly/assignment_orders.php.expectf [new file with mode: 0644]
hphp/test/slow/readonly/pipe_expression_assignment_order.php [new file with mode: 0644]
hphp/test/slow/readonly/pipe_expression_assignment_order.php.expectf [new file with mode: 0644]