Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using nameof syntax leads to parse errors #9447

Open
varungandhi-src opened this issue Jun 2, 2024 · 1 comment
Open

Using nameof syntax leads to parse errors #9447

varungandhi-src opened this issue Jun 2, 2024 · 1 comment

Comments

@varungandhi-src
Copy link

Describe the bug

The code examples on the nameof page lead to parse errors.

Standalone code, or other way to reproduce the problem

class B {}
class C extends B {}
trait T {
    require extends B;
    public static function f(): void {
        var_dump(nameof T); // "T"
        var_dump(nameof self); // "D" (user of trait)
        var_dump(nameof parent); // "C" (parent of trait user, not B)
        var_dump(nameof static); // "E", receiver for ::f() in main
    }
}
class D extends C { use T; }
class E extends D {}

<<__EntryPoint>>
function main(): void {
  E::f();
}

Steps to reproduce the behavior:

  1. Copy-paste the above code in tmp.hack and run hhvm tmp.hack. I tested with the Docker container

Expected behavior

Code should run (or at least parse) properly.

Actual behavior

Fatal error: Encountered unexpected token `T`. in /home/tmp.hack on line 6

Environment

  • Operating system: macOS Sonoma 14.2.1
  • Installation method: Docker hhvm/hhvm:latest with sha256:1cc1be0d469a378114112096431145c9fe80612c61ba48e8697097d933147f60
  • HHVM Version
HipHop VM 4.172.0 (rel) (non-lowptr)
Compiler: 1667340154_989010953
Repo schema: 63eaf8b56fb7edbc7a8ca9e32786eb0c1f8f508c

Additional context

We're trying to add support for Hack syntax highlighting in Sourcegraph here: sourcegraph/sourcegraph#62770 and were going through the official docs for code examples.

@lexidor
Copy link
Collaborator

lexidor commented Jun 4, 2024

The version of hhvm you are using is not the latest version. nameof is very new. Your version of hhvm does not support this syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants