Skip to content

Commit 824a4ab

Browse files
committed
Add back support for Zend/tests/list/bug73663.phpt
1 parent 7f5e296 commit 824a4ab

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

Zend/tests/list/bug73663.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Bug #73663 ("Invalid opcode 65/16/8" occurs with a variable created with list())
3-
--XFAIL--
4-
list() assign resulting in a ref only when there's a single by-ref fetch is kinda weird.
53
--FILE--
64
<?php
75
function change(&$ref) {

Zend/zend_compile.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static zend_op *zend_compile_var(znode *result, zend_ast *ast, uint32_t type, bo
101101
static zend_op *zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type, bool by_ref);
102102
static void zend_compile_expr(znode *result, zend_ast *ast);
103103
static void zend_compile_stmt(zend_ast *ast);
104-
static void zend_compile_assign(znode *result, zend_ast *ast, bool stmt);
104+
static void zend_compile_assign(znode *result, zend_ast *ast, bool stmt, uint32_t type);
105105

106106
#ifdef ZEND_CHECK_STACK_LIMIT
107107
zend_never_inline static void zend_stack_limit_error(void)
@@ -2735,14 +2735,24 @@ void zend_emit_final_return(bool return_one) /* {{{ */
27352735
}
27362736
/* }}} */
27372737

2738+
static bool zend_propagate_list_refs(zend_ast *ast);
2739+
27382740
static inline bool zend_is_variable(const zend_ast *ast) /* {{{ */
27392741
{
2740-
return ast->kind == ZEND_AST_VAR
2742+
if (ast->kind == ZEND_AST_VAR
27412743
|| ast->kind == ZEND_AST_DIM
27422744
|| ast->kind == ZEND_AST_PROP
27432745
|| ast->kind == ZEND_AST_NULLSAFE_PROP
27442746
|| ast->kind == ZEND_AST_STATIC_PROP
2745-
|| ast->kind == ZEND_AST_ASSIGN_REF;
2747+
|| ast->kind == ZEND_AST_ASSIGN_REF) {
2748+
return true;
2749+
}
2750+
if (ast->kind == ZEND_AST_ASSIGN
2751+
&& UNEXPECTED(ast->child[0]->kind == ZEND_AST_ARRAY)
2752+
&& zend_propagate_list_refs(ast->child[0])) {
2753+
return true;
2754+
}
2755+
return false;
27462756
}
27472757
/* }}} */
27482758

@@ -3483,7 +3493,7 @@ static void zend_compile_expr_with_potential_assign_to_self(
34833493
}
34843494
}
34853495

3486-
static void zend_compile_assign(znode *result, zend_ast *ast, bool stmt) /* {{{ */
3496+
static void zend_compile_assign(znode *result, zend_ast *ast, bool stmt, uint32_t type) /* {{{ */
34873497
{
34883498
zend_ast *var_ast = ast->child[0];
34893499
zend_ast *expr_ast = ast->child[1];
@@ -3573,7 +3583,7 @@ static void zend_compile_assign(znode *result, zend_ast *ast, bool stmt) /* {{{
35733583
}
35743584
}
35753585

3576-
zend_compile_list_assign(!stmt ? result : NULL, var_ast, &expr_node, var_ast->attr, BP_VAR_R);
3586+
zend_compile_list_assign(!stmt ? result : NULL, var_ast, &expr_node, var_ast->attr, type);
35773587
if (stmt) {
35783588
result->op_type = IS_UNUSED;
35793589
}
@@ -12068,7 +12078,7 @@ static void zend_compile_stmt(zend_ast *ast) /* {{{ */
1206812078
break;
1206912079
case ZEND_AST_ASSIGN: {
1207012080
znode result;
12071-
zend_compile_assign(&result, ast, /* stmt */ true);
12081+
zend_compile_assign(&result, ast, /* stmt */ true, BP_VAR_R);
1207212082
zend_do_free(&result);
1207312083
return;
1207412084
}
@@ -12121,7 +12131,7 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
1212112131
zend_compile_var(result, ast, BP_VAR_R, false);
1212212132
return;
1212312133
case ZEND_AST_ASSIGN:
12124-
zend_compile_assign(result, ast, /* stmt */ false);
12134+
zend_compile_assign(result, ast, /* stmt */ false, BP_VAR_R);
1212512135
return;
1212612136
case ZEND_AST_ASSIGN_REF:
1212712137
zend_compile_assign_ref(result, ast, BP_VAR_R);
@@ -12292,6 +12302,10 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
1229212302
case ZEND_AST_ASSIGN_REF:
1229312303
zend_compile_assign_ref(result, ast, type);
1229412304
return NULL;
12305+
case ZEND_AST_ASSIGN:
12306+
ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_ARRAY && zend_propagate_list_refs(ast->child[0]));
12307+
zend_compile_assign(result, ast, false, type);
12308+
return NULL;
1229512309
default:
1229612310
if (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) {
1229712311
zend_error_noreturn(E_COMPILE_ERROR,

0 commit comments

Comments
 (0)