File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -914,6 +914,15 @@ non_empty_argument_list:
914914 { $$ = zend_ast_list_add($1 , $3 ); }
915915;
916916
917+ /* `clone_argument_list` is necessary to resolve a parser ambiguity (shift-reduce conflict)
918+ * of `clone($expr)`, which could either be parsed as a function call with `$expr` as the first
919+ * argument or as a use of the `clone` language construct with an expression with useless
920+ * parenthesis. Both would be valid and result in the same AST / the same semantics.
921+ * `clone_argument_list` is defined in a way that an `expr` in the first position needs to
922+ * be followed by a `,` which is not valid syntax for a parenthesized `expr`, ensuring
923+ * that calling `clone()` with a single unnamed parameter is handled by the language construct
924+ * syntax.
925+ */
917926clone_argument_list :
918927 ' (' ' )' { $$ = zend_ast_create_list(0 , ZEND_AST_ARG_LIST); }
919928 | ' (' non_empty_clone_argument_list possible_comma ' )' { $$ = $2 ; }
You can’t perform that action at this time.
0 commit comments