diff --git a/Zend/tests/bug71529.phpt b/Zend/tests/bug71529.phpt new file mode 100644 index 00000000000..5a5e3234145 --- /dev/null +++ b/Zend/tests/bug71529.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #71529: Variable references on array elements don't work when using count +--FILE-- + +--EXPECT-- +int(0) +array(2) { + [0]=> + &int(1) + [1]=> + &int(1) +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 8ac98191354..f324e52874e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2887,14 +2887,17 @@ void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */ znode target_node, source_node; zend_op *opline; + uint32_t offset; if (is_this_fetch(target_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign $this"); } zend_ensure_writable_variable(target_ast); - zend_compile_var(&target_node, target_ast, BP_VAR_W); - zend_compile_var(&source_node, source_ast, BP_VAR_W); + offset = zend_delayed_compile_begin(); + zend_delayed_compile_var(&target_node, target_ast, BP_VAR_W); + zend_delayed_compile_var(&source_node, source_ast, BP_VAR_W); + zend_delayed_compile_end(offset); if (source_node.op_type != IS_VAR && zend_is_call(source_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use result of built-in function in write context");