-
Notifications
You must be signed in to change notification settings - Fork 8k
[PFA 1/n] Support PFA syntax #20717
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
base: master
Are you sure you want to change the base?
[PFA 1/n] Support PFA syntax #20717
Changes from all commits
677e251
905b311
1ac09e0
a65e668
098862d
54b61c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --TEST-- | ||
| First class callable error: more than one argument | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| foo(1, ...); | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Cannot create a Closure for call expression with more than one argument, or non-variadic placeholders in %s on line %d |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --TEST-- | ||
| First class callable error: non-variadic placeholder | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| foo(?); | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Cannot create a Closure for call expression with more than one argument, or non-variadic placeholders in %s on line %d |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -901,16 +901,15 @@ return_type: | |
| ; | ||
|
|
||
| argument_list: | ||
| '(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); } | ||
| '(' ')' { $$ = zend_ast_create_arg_list(0, ZEND_AST_ARG_LIST); } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. zend_ast_create_arg_list is always used with ZEND_AST_ARG_LIST. Looks a bit redundant but perhaps this is for the future proofing.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered this, but the variadic specialization trick implicitly expects the
|
||
| | '(' non_empty_argument_list possible_comma ')' { $$ = $2; } | ||
| | '(' T_ELLIPSIS ')' { $$ = zend_ast_create_fcc(); } | ||
| ; | ||
|
|
||
| non_empty_argument_list: | ||
| argument | ||
| { $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1); } | ||
| { $$ = zend_ast_create_arg_list(1, ZEND_AST_ARG_LIST, $1); } | ||
| | non_empty_argument_list ',' argument | ||
| { $$ = zend_ast_list_add($1, $3); } | ||
| { $$ = zend_ast_arg_list_add($1, $3); } | ||
| ; | ||
|
|
||
| /* `clone_argument_list` is necessary to resolve a parser ambiguity (shift-reduce conflict) | ||
|
|
@@ -923,25 +922,31 @@ non_empty_argument_list: | |
| * syntax. | ||
| */ | ||
| clone_argument_list: | ||
| '(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); } | ||
| '(' ')' { $$ = zend_ast_create_arg_list(0, ZEND_AST_ARG_LIST); } | ||
| | '(' non_empty_clone_argument_list possible_comma ')' { $$ = $2; } | ||
| | '(' expr ',' ')' { $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $2); } | ||
| | '(' T_ELLIPSIS ')' { $$ = zend_ast_create_fcc(); } | ||
| | '(' expr ',' ')' { $$ = zend_ast_create_arg_list(1, ZEND_AST_ARG_LIST, $2); } | ||
| ; | ||
|
|
||
| non_empty_clone_argument_list: | ||
| expr ',' argument | ||
| { $$ = zend_ast_create_list(2, ZEND_AST_ARG_LIST, $1, $3); } | ||
| { $$ = zend_ast_create_arg_list(2, ZEND_AST_ARG_LIST, $1, $3); } | ||
| | argument_no_expr | ||
| { $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1); } | ||
| { $$ = zend_ast_create_arg_list(1, ZEND_AST_ARG_LIST, $1); } | ||
| | non_empty_clone_argument_list ',' argument | ||
| { $$ = zend_ast_list_add($1, $3); } | ||
| { $$ = zend_ast_arg_list_add($1, $3); } | ||
| ; | ||
|
|
||
| argument_no_expr: | ||
| identifier ':' expr | ||
| { $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, $3); } | ||
| | T_ELLIPSIS expr { $$ = zend_ast_create(ZEND_AST_UNPACK, $2); } | ||
| | T_ELLIPSIS | ||
| { $$ = zend_ast_create_ex(ZEND_AST_PLACEHOLDER_ARG, ZEND_PLACEHOLDER_VARIADIC); } | ||
| | '?' | ||
| { $$ = zend_ast_create(ZEND_AST_PLACEHOLDER_ARG); } | ||
| | identifier ':' '?' | ||
| { $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, zend_ast_create(ZEND_AST_PLACEHOLDER_ARG)); } | ||
| | T_ELLIPSIS expr | ||
| { $$ = zend_ast_create(ZEND_AST_UNPACK, $2); } | ||
| ; | ||
|
|
||
| argument: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is clearer (the
fcc_astdoesn't actually change):There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer
return (zend_ast*)fcc_ast, but no strong opinion