-
Notifications
You must be signed in to change notification settings - Fork 68
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
invalid ast for self
and parent
#235
Comments
Any ideas how we can fix? I try but looks it is not easy. Oh, we can't update parser around 10-20 commits due only regressions 😞 |
Hi, this behavior was introduced here : php-parser/src/parser/namespace.js Line 76 in cf064c0
The reason is that the read_variable is used in many parsing contexts, and we introduced this change only for handling the Take a look at the tests/debug.js, it's an helper in order to run step by step the parser and create breakpoints with vscode, it will help you in the future to debug more easily. Here the full story from the https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y :
And actually the code says : /**
* Reads a class name
* ```ebnf
* class_name_reference ::= namespace_name | variable
* ```
*/
read_class_name_reference: function() {
if (
this.token === this.tok.T_NS_SEPARATOR ||
this.token === this.tok.T_STRING ||
this.token === this.tok.T_NAMESPACE
) {
let result = this.read_namespace_name();
if (this.token === this.tok.T_DOUBLE_COLON) {
result = this.read_static_getter(result);
}
return result;
} else if (this.is("VARIABLE")) {
return this.read_variable(true, false, false);
} else {
this.expect([this.tok.T_STRING, "VARIABLE"]);
} We have here multiple problems, first the Also the The problem here it's the look ahead, you can't know how to resolve the type without knowing the next token. The solution here is to check it before resolving the type of node. |
it's fixed, you can test and if it's OK for you we can close this issue |
released in |
Input:
Resolves as
SelfReference
andParentReference
, but it is invalidThe text was updated successfully, but these errors were encountered: