@@ -2460,6 +2460,13 @@ static bool zend_ast_is_short_circuited(const zend_ast *ast)
2460
2460
}
2461
2461
}
2462
2462
2463
+ static void zend_assert_not_short_circuited (const zend_ast * ast )
2464
+ {
2465
+ if (zend_ast_is_short_circuited (ast )) {
2466
+ zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
2467
+ }
2468
+ }
2469
+
2463
2470
/* Mark nodes that are an inner part of a short-circuiting chain.
2464
2471
* We should not perform a "commit" on them, as it will be performed by the outer-most node.
2465
2472
* We do this to avoid passing down an argument in various compile functions. */
@@ -3463,9 +3470,8 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
3463
3470
if (!zend_is_variable_or_call (expr_ast )) {
3464
3471
zend_error_noreturn (E_COMPILE_ERROR ,
3465
3472
"Cannot assign reference to non referenceable value" );
3466
- } else if (zend_ast_is_short_circuited (expr_ast )) {
3467
- zend_error_noreturn (E_COMPILE_ERROR ,
3468
- "Cannot take reference of a nullsafe chain" );
3473
+ } else {
3474
+ zend_assert_not_short_circuited (expr_ast );
3469
3475
}
3470
3476
3471
3477
zend_compile_var (& expr_node , expr_ast , BP_VAR_W , 1 );
@@ -3507,9 +3513,7 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */
3507
3513
zend_error_noreturn (E_COMPILE_ERROR , "Cannot re-assign $this" );
3508
3514
}
3509
3515
zend_ensure_writable_variable (target_ast );
3510
- if (zend_ast_is_short_circuited (source_ast )) {
3511
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
3512
- }
3516
+ zend_assert_not_short_circuited (source_ast );
3513
3517
if (is_globals_fetch (source_ast )) {
3514
3518
zend_error_noreturn (E_COMPILE_ERROR , "Cannot acquire reference to $GLOBALS" );
3515
3519
}
@@ -5543,10 +5547,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */
5543
5547
expr_node .op_type = IS_CONST ;
5544
5548
ZVAL_NULL (& expr_node .u .constant );
5545
5549
} else if (by_ref && zend_is_variable (expr_ast )) {
5546
- if (zend_ast_is_short_circuited (expr_ast )) {
5547
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
5548
- }
5549
-
5550
+ zend_assert_not_short_circuited (expr_ast );
5550
5551
zend_compile_var (& expr_node , expr_ast , BP_VAR_W , 1 );
5551
5552
} else {
5552
5553
zend_compile_expr (& expr_node , expr_ast );
@@ -9936,6 +9937,7 @@ static void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */
9936
9937
9937
9938
if (value_ast ) {
9938
9939
if (returns_by_ref && zend_is_variable (value_ast )) {
9940
+ zend_assert_not_short_circuited (value_ast );
9939
9941
zend_compile_var (& value_node , value_ast , BP_VAR_W , 1 );
9940
9942
} else {
9941
9943
zend_compile_expr (& value_node , value_ast );
0 commit comments