Skip to content

Comments between object operator and semi-reserved name result in parse error #14961

Closed
@bwoebi

Description

@bwoebi

Description

The following code:

<?php

class A {
    public $class = A::class;
}

var_dump((new A)-> /* a meaningful comment */ class);

Resulted in this output:

Parse error: syntax error, unexpected token "class", expecting identifier or variable or "{" or "$" in /in/8t7hs on line 7

But I expected this output instead:

string(1) "A"

Looks like we're popping out of ST_LOOKING_FOR_PROPERTY when encountering a comment, leaving us in a bad state.

PHP Version

master (all versions of PHP 8)

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions