Tighten up ::class syntax
commit4491f02bf0ec7419fb739fd4c67c6775d9b863bc
authorThomas Jiang <thomasjiang@fb.com>
Fri, 3 Jul 2020 03:59:49 +0000 (2 20:59 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 3 Jul 2020 04:13:02 +0000 (2 21:13 -0700)
tree10afa9e84666fcf9fd21a3c64de38ef7724ca167
parentf8e87bb42ebb8bb6456f654e6927710fcf5f0955
Tighten up ::class syntax

Summary:
Previously, we allowed the following syntax in the emitter
```
'MyClass'::class
```
Which was similar to
```
MyClass::class
```
However, 'MyClass'::class also causes MyClass to be loaded (unlike a usual ::class expression) since the bytecode we emit is something like
```
String "MyClass"
ClassGetC
ClassName
```
We should instead just put the classname directly there instead of wrapping it in a string.

This was banned in the typechecker as a "parse" error - though we did not trigger it in non-typechecker codepaths.

We want to change this as part of our effort to tighten up classname for class pointer and function pointer rollout. This diff fires this error (and other previously only typechecker path parse errors related to bad syntax involving `::class:`) occur in all codepaths instead of just the typechecker only path.

Reviewed By: periodic1236

Differential Revision: D22170448

fbshipit-source-id: 132f36fff1fb74daddc176934d520daec4a5653b
hphp/hack/src/parser/rust_parser_errors.rs
hphp/hack/test/typecheck/classname/via_string.php [new file with mode: 0644]
hphp/hack/test/typecheck/classname/via_string.php.exp [new file with mode: 0644]
hphp/test/slow/dynamic-calls/string-classname.php [new file with mode: 0644]
hphp/test/slow/dynamic-calls/string-classname.php.expectf [new file with mode: 0644]