@@ -2438,6 +2438,13 @@ static bool zend_ast_is_short_circuited(const zend_ast *ast)
2438
2438
}
2439
2439
}
2440
2440
2441
+ static void zend_assert_not_short_circuited (const zend_ast * ast )
2442
+ {
2443
+ if (zend_ast_is_short_circuited (ast )) {
2444
+ zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
2445
+ }
2446
+ }
2447
+
2441
2448
/* Mark nodes that are an inner part of a short-circuiting chain.
2442
2449
* We should not perform a "commit" on them, as it will be performed by the outer-most node.
2443
2450
* We do this to avoid passing down an argument in various compile functions. */
@@ -3426,9 +3433,8 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
3426
3433
if (!zend_is_variable_or_call (expr_ast )) {
3427
3434
zend_error_noreturn (E_COMPILE_ERROR ,
3428
3435
"Cannot assign reference to non referenceable value" );
3429
- } else if (zend_ast_is_short_circuited (expr_ast )) {
3430
- zend_error_noreturn (E_COMPILE_ERROR ,
3431
- "Cannot take reference of a nullsafe chain" );
3436
+ } else {
3437
+ zend_assert_not_short_circuited (expr_ast );
3432
3438
}
3433
3439
3434
3440
zend_compile_var (& expr_node , expr_ast , BP_VAR_W , 1 );
@@ -3470,9 +3476,7 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */
3470
3476
zend_error_noreturn (E_COMPILE_ERROR , "Cannot re-assign $this" );
3471
3477
}
3472
3478
zend_ensure_writable_variable (target_ast );
3473
- if (zend_ast_is_short_circuited (source_ast )) {
3474
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
3475
- }
3479
+ zend_assert_not_short_circuited (source_ast );
3476
3480
if (is_globals_fetch (source_ast )) {
3477
3481
zend_error_noreturn (E_COMPILE_ERROR , "Cannot acquire reference to $GLOBALS" );
3478
3482
}
@@ -5173,10 +5177,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */
5173
5177
expr_node .op_type = IS_CONST ;
5174
5178
ZVAL_NULL (& expr_node .u .constant );
5175
5179
} else if (by_ref && zend_is_variable (expr_ast )) {
5176
- if (zend_ast_is_short_circuited (expr_ast )) {
5177
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
5178
- }
5179
-
5180
+ zend_assert_not_short_circuited (expr_ast );
5180
5181
zend_compile_var (& expr_node , expr_ast , BP_VAR_W , 1 );
5181
5182
} else {
5182
5183
zend_compile_expr (& expr_node , expr_ast );
@@ -9512,6 +9513,7 @@ static void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */
9512
9513
9513
9514
if (value_ast ) {
9514
9515
if (returns_by_ref && zend_is_variable (value_ast )) {
9516
+ zend_assert_not_short_circuited (value_ast );
9515
9517
zend_compile_var (& value_node , value_ast , BP_VAR_W , 1 );
9516
9518
} else {
9517
9519
zend_compile_expr (& value_node , value_ast );
0 commit comments