Refactor / consolidate capability checks covered by parser and typechecker
commitdd4196869ce395bb0f731c74254b0bbc0e43b5cf
authorHunter Goldstein <hgoldstein@fb.com>
Fri, 15 Jul 2022 18:09:05 +0000 (15 11:09 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 15 Jul 2022 18:09:05 +0000 (15 11:09 -0700)
tree2cd576096b83cd38718b761b5d92ddf2727163a4
parentc969aa61f4131f3a8e44b86d970db8d2a7c0372e
Refactor / consolidate capability checks covered by parser and typechecker

Summary:
At some point during capability / context development, we added parser checks for some constructs like:
* Accessing static variables without `read_globals` / `globals`
* Writing to properties without `write_props`

The parser checks can be bypassed with `__IgnoreCoeffectLocalErrors`, but you end up still running into the typechecker errors. Given they're duplicated ... let's just nix the typechecker errors.

I've also backported one pattern the typechecker caught but the parser didn't which is doing something like:
```
enum class Foo: mixed {
  mixed X = Bar::$baz;
}
```

The typechecker caught this is illegal, as enum class initializers don't have `read_globals`, but the parser accepted this code.

Reviewed By: chenmela

Differential Revision: D37726100

fbshipit-source-id: fce3a709ac1f37649d49e0828b3c73154e0c3323
15 files changed:
hphp/hack/src/parser/coeffects_check.rs
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_local_ops.ml
hphp/hack/src/typing/typing_local_ops.mli
hphp/hack/test/typecheck/access_globals/write_static_prop_errors.php.exp
hphp/hack/test/typecheck/coeffects/default-arg/static_prop.php.exp
hphp/hack/test/typecheck/coeffects/local/globals_static_property.php.exp
hphp/hack/test/typecheck/coeffects/read_globals/read_static_prop_error.php.exp
hphp/hack/test/typecheck/coeffects/read_globals/read_static_prop_lambda_error.php.exp
hphp/hack/test/typecheck/coeffects/read_globals/readonly_statics.php.exp
hphp/hack/test/typecheck/coeffects/strict-contexts/leak_safe_local-ops.php.exp
hphp/hack/test/typecheck/enum_class/coeffects-read-global.php [new file with mode: 0644]
hphp/hack/test/typecheck/enum_class/coeffects-read-global.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/readonly/policied_static_prop.php.exp
hphp/hack/test/typecheck/static_in_prop_decl.php.exp