@@ -2312,6 +2312,13 @@ static bool zend_ast_is_short_circuited(const zend_ast *ast)
2312
2312
}
2313
2313
}
2314
2314
2315
+ static void zend_assert_not_short_circuited (const zend_ast * ast )
2316
+ {
2317
+ if (zend_ast_is_short_circuited (ast )) {
2318
+ zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
2319
+ }
2320
+ }
2321
+
2315
2322
/* Mark nodes that are an inner part of a short-circuiting chain.
2316
2323
* We should not perform a "commit" on them, as it will be performed by the outer-most node.
2317
2324
* We do this to avoid passing down an argument in various compile functions. */
@@ -3304,9 +3311,8 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
3304
3311
if (!zend_is_variable_or_call (expr_ast )) {
3305
3312
zend_error_noreturn (E_COMPILE_ERROR ,
3306
3313
"Cannot assign reference to non referenceable value" );
3307
- } else if (zend_ast_is_short_circuited (expr_ast )) {
3308
- zend_error_noreturn (E_COMPILE_ERROR ,
3309
- "Cannot take reference of a nullsafe chain" );
3314
+ } else {
3315
+ zend_assert_not_short_circuited (expr_ast );
3310
3316
}
3311
3317
3312
3318
zend_compile_var (& expr_node , expr_ast , BP_VAR_W , 1 );
@@ -3348,9 +3354,7 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */
3348
3354
zend_error_noreturn (E_COMPILE_ERROR , "Cannot re-assign $this" );
3349
3355
}
3350
3356
zend_ensure_writable_variable (target_ast );
3351
- if (zend_ast_is_short_circuited (source_ast )) {
3352
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
3353
- }
3357
+ zend_assert_not_short_circuited (source_ast );
3354
3358
if (is_globals_fetch (source_ast )) {
3355
3359
zend_error_noreturn (E_COMPILE_ERROR , "Cannot acquire reference to $GLOBALS" );
3356
3360
}
@@ -5026,10 +5030,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */
5026
5030
expr_node .op_type = IS_CONST ;
5027
5031
ZVAL_NULL (& expr_node .u .constant );
5028
5032
} else if (by_ref && zend_is_variable (expr_ast )) {
5029
- if (zend_ast_is_short_circuited (expr_ast )) {
5030
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
5031
- }
5032
-
5033
+ zend_assert_not_short_circuited (expr_ast );
5033
5034
zend_compile_var (& expr_node , expr_ast , BP_VAR_W , 1 );
5034
5035
} else {
5035
5036
zend_compile_expr (& expr_node , expr_ast );
@@ -9329,10 +9330,7 @@ static void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */
9329
9330
9330
9331
if (value_ast ) {
9331
9332
if (returns_by_ref && zend_is_variable (value_ast )) {
9332
- if (zend_ast_is_short_circuited (value_ast )) {
9333
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot take reference of a nullsafe chain" );
9334
- }
9335
-
9333
+ zend_assert_not_short_circuited (value_ast );
9336
9334
zend_compile_var (& value_node , value_ast , BP_VAR_W , 1 );
9337
9335
} else {
9338
9336
zend_compile_expr (& value_node , value_ast );
0 commit comments