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

staticlookup is broken with curly #167

Closed
alexander-akait opened this issue Jul 24, 2018 · 4 comments
Closed

staticlookup is broken with curly #167

alexander-akait opened this issue Jul 24, 2018 · 4 comments
Assignees

Comments

@alexander-akait
Copy link
Collaborator

alexander-akait commented Jul 24, 2018

Input:

$var = Foo::{$bar['baz']}();

Output: SyntaxError: Parse Error : syntax error, unexpected '{' on line 35

@alexander-akait
Copy link
Collaborator Author

/cc @ichiriac I have some question about this?

Foo::{$bar['baz']}(); is parsed now and we have valid ast, but
Foo::$bar['baz'](); is parsed now too, but we have invalid ast.

Now we have same ast, but for second should be:

  • call
    • offsetlookup
      • staticlookup

Any ideas where i should fix it?

@ichiriac
Copy link
Member

Related to #233 from this merge #225

You can read the explanation from the PR, it explains the bug, and if you don't find I'll fix it later, this is a minor bug

@ichiriac
Copy link
Member

Ok, after reading again and trying with PHP, it's true about new keywords, but here we are dealing with member_name.

Here the php definition :

function_call:
		name argument_list
	|	class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
	|	variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
	|	callable_expr argument_list
;
member_name:
		identifier
	|	'{' expr '}'
	|	simple_variable
;
identifier:
		T_STRING 
	| 	semi_reserved  
;
simple_variable:
		T_VARIABLE
	|	'$' '{' expr '}'
	|	'$' simple_variable
;

As you can see, Foo::$bar['baz'](); is not a valid class_name T_PAAMAYIM_NEKUDOTAYIM member_name because of ['baz'], but it's a callable_expr.

Next you need to run the code in step-by-step in order to understand the execution flow :

  • node <- read_static_getter -> read_reference_variable -> eating []
  • recursive_variable_chain_scan -> eating ()

The recursive_variable_chain_scan can also eat [] and it translates correctly nodes, so to fix this, you have just to disable the eating of [] into read_reference_variable, it was just too early

@ichiriac
Copy link
Member

ichiriac commented Jan 7, 2019

released in 3.0.0-prerelease.8

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

No branches or pull requests

2 participants