@@ -6417,23 +6417,26 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
64176417 zend_ast * operand_ast = ast -> child [0 ];
64186418 zend_ast * callable_ast = ast -> child [1 ];
64196419
6420+ // Execute everything on the left side first, down to a value.
64206421 znode operand_result ;
64216422 zend_compile_expr (& operand_result , operand_ast );
6423+
6424+ // Wrap the operand in a ZEND_QM_ASSIGN to prevent references
6425+ // from working in all cases. (Otherwise they'd fail only in some.)
64226426 znode wrapped_operand_result ;
64236427 zend_emit_op_tmp (& wrapped_operand_result , ZEND_QM_ASSIGN , & operand_result , NULL );
64246428
6425- /* Turn $foo |> bar(...) into bar($foo). */
6429+ // Turn $foo |> bar(...) into bar($foo).
64266430 if (callable_ast -> kind == ZEND_AST_CALL
64276431 && callable_ast -> child [1 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
64286432 callable_ast = callable_ast -> child [0 ];
6433+ } else {
6434+ znode callable_result ;
6435+ callable_ast = zend_ast_create_znode (& callable_result );
6436+ zend_compile_expr (& callable_result , callable_ast );
64296437 }
64306438
6431- znode callable_result ;
6432- zend_compile_expr (& callable_result , callable_ast );
6433-
6434- zend_ast * fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6435- zend_ast_create_znode (& callable_result ),
6436- zend_ast_create_list (1 , ZEND_AST_ARG_LIST , zend_ast_create_znode (& wrapped_operand_result )));
6439+ zend_ast * fcall_ast = zend_ast_create_list (1 , ZEND_AST_ARG_LIST , zend_ast_create_znode (& wrapped_operand_result ));
64376440
64386441 zend_compile_expr (result , fcall_ast );
64396442}
0 commit comments