Special function supportnightly-2021.10.12
commitcb61163b1c7f08a8504c959689f98abb88bc33c9
authorJames Wu <jjwu@fb.com>
Tue, 12 Oct 2021 02:10:59 +0000 (11 19:10 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 12 Oct 2021 02:12:39 +0000 (11 19:12 -0700)
tree6479f299de64fdb5d22401bf910352ca56c9097b
parent7ecf7740ffc2e95ccf45fb6c4a3ffccbd8dd789f
Special function support

Summary:
Special functions like vec(), dict(), keyset(), etc. are all special functions which don't have actual function implementations. Instead they emit special bytecodes in HackC.

Therefore, we can/need to support them specially in readonly's case. The good news here is that we can make them polymorphic, which improves the user experience. vec(), dict(), etc will return a readonly collection if their first argument is readonly, and a mutable collection otherwise.

Reviewed By: oulgen

Differential Revision: D31531162

fbshipit-source-id: 9676afc7de19d72e9044b5e2844286f89f4d7f94
13 files changed:
hphp/hack/Cargo.lock
hphp/hack/src/parser/cargo/aast_parser/Cargo.toml
hphp/hack/src/parser/hh_autoimport.rs
hphp/hack/src/parser/readonly_check.rs
hphp/hack/src/typing/tast_check/readonly_check.ml
hphp/hack/test/typecheck/readonly/vec_special_builtin.php [new file with mode: 0644]
hphp/hack/test/typecheck/readonly/vec_special_builtin.php.exp [new file with mode: 0644]
hphp/test/slow/readonly/dict_function.php [new file with mode: 0644]
hphp/test/slow/readonly/dict_function.php.expectf [new file with mode: 0644]
hphp/test/slow/readonly/hphp_array_idx.php [new file with mode: 0644]
hphp/test/slow/readonly/hphp_array_idx.php.expectf [new file with mode: 0644]
hphp/test/slow/readonly/vec_function.php [new file with mode: 0644]
hphp/test/slow/readonly/vec_function.php.expectf [new file with mode: 0644]