eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
188 stars 46 forks source link

The ast parser >=8.1 cannot correctly handle T_REFERENCE_FOLLOWED_BY_VAR_OR_VARARG #275

Closed nabice closed 2 months ago

nabice commented 2 months ago

Sample Code:

<?php
$a & $b;

return an ASTError Node.

nabice commented 2 months ago

My test code:

import org.eclipse.php.core.PHPVersion;
import org.eclipse.php.core.ast.nodes.*;

public class Test {
    public static void main(String[] args) {
        String str = "<?php\n $a & $b;?> ";
        try{
            ASTParser parser = ASTParser.newParser(PHPVersion.PHP8_3, false, false);
            parser.setSource(str.toCharArray());
            AST ast = parser.createAST(null).getAST();
            System.out.println(ast);
        } catch (Throwable e) {
        }
    }
}

Output: Syntax error at character 10 of input

PHP8_0 is OK.