@@ -6417,23 +6417,26 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
6417
6417
zend_ast * operand_ast = ast -> child [0 ];
6418
6418
zend_ast * callable_ast = ast -> child [1 ];
6419
6419
6420
+ // Execute everything on the left side first, down to a value.
6420
6421
znode operand_result ;
6421
6422
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.)
6422
6426
znode wrapped_operand_result ;
6423
6427
zend_emit_op_tmp (& wrapped_operand_result , ZEND_QM_ASSIGN , & operand_result , NULL );
6424
6428
6425
- /* Turn $foo |> bar(...) into bar($foo). */
6429
+ // Turn $foo |> bar(...) into bar($foo).
6426
6430
if (callable_ast -> kind == ZEND_AST_CALL
6427
6431
&& callable_ast -> child [1 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
6428
6432
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 );
6429
6437
}
6430
6438
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 ));
6437
6440
6438
6441
zend_compile_expr (result , fcall_ast );
6439
6442
}
0 commit comments