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

bug in parser with single function #180

Closed
alexander-akait opened this issue Sep 11, 2018 · 3 comments
Closed

bug in parser with single function #180

alexander-akait opened this issue Sep 11, 2018 · 3 comments
Assignees
Labels
bug high-pri High Priority bug major Major issue - have a real impact on many cases PARSER php7

Comments

@alexander-akait
Copy link
Collaborator

function foo() {
    function () {};
    (function () {});
}

php parser works well

@alexander-akait
Copy link
Collaborator Author

Same problem with

<?php

function () {};

@ichiriac ichiriac self-assigned this Sep 12, 2018
@ichiriac ichiriac added high-pri High Priority bug major Major issue - have a real impact on many cases labels Jan 7, 2019
@ichiriac ichiriac added this to the 3.0.0-prerelease.9 milestone Jan 7, 2019
@ichiriac
Copy link
Member

ichiriac commented Aug 9, 2019

that's specific to PHP 7.4 (a part of new introduced syntax)
https://wiki.php.net/rfc/arrow_functions_v2

Commit :
php/php-src@f3e5bbe

Definition
https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L999

inline_function:
		function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type
		backup_fn_flags '{' inner_statement_list '}' backup_fn_flags
			{ $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2 | $13, $1, $3,
				  zend_string_init("{closure}", sizeof("{closure}") - 1, 0),
				  $5, $7, $11, $8); CG(extra_fn_flags) = $9; }
	|	fn returns_ref '(' parameter_list ')' return_type backup_doc_comment T_DOUBLE_ARROW backup_fn_flags backup_lex_pos expr backup_fn_flags
			{ $$ = zend_ast_create_decl(ZEND_AST_ARROW_FUNC, $2 | $12, $1, $7,
				  zend_string_init("{closure}", sizeof("{closure}") - 1, 0), $4, NULL,
				  zend_ast_create(ZEND_AST_RETURN, $11), $6);
				  ((zend_ast_decl *) $$)->lex_pos = $10;
				  CG(extra_fn_flags) = $9; }
;

@ichiriac ichiriac removed the php5 label Aug 9, 2019
ichiriac added a commit that referenced this issue Aug 9, 2019
@ichiriac ichiriac added the RELEASE-READY Waiting to release label Aug 9, 2019
@alexander-akait
Copy link
Collaborator Author

Yes, in php7.4 we have arrow functions, need fix it

@ichiriac ichiriac removed the RELEASE-READY Waiting to release label Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug high-pri High Priority bug major Major issue - have a real impact on many cases PARSER php7
Projects
None yet
Development

No branches or pull requests

2 participants