Commit a01a8e72acd for php.net
commit a01a8e72acdf3cba61abe51b7408968dcc81da09
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date: Sun Feb 1 14:13:31 2026 +0100
Fix failed assertion for assignment in expression context
This code path is reachable for all assignments expressions, not just true
variable expressions.
Really surprising we have no tests that caught this.
diff --git a/Zend/tests/gh20628_005.phpt b/Zend/tests/gh20628_005.phpt
new file mode 100644
index 00000000000..43b49e0c18f
--- /dev/null
+++ b/Zend/tests/gh20628_005.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Failed assertion for assignment in expression context
+--CREDITS--
+Matteo Beccati (mbeccati)
+--FILE--
+<?php
+
+function foo() {
+ return ['bar' => 'baz'];
+}
+
+var_dump(($v = foo())['bar'], $v);
+
+?>
+--EXPECT--
+string(3) "baz"
+array(1) {
+ ["bar"]=>
+ string(3) "baz"
+}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 325953e158e..a013efab859 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -12303,7 +12303,6 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
zend_compile_assign_ref(result, ast, type);
return NULL;
case ZEND_AST_ASSIGN:
- ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_ARRAY && zend_propagate_list_refs(ast->child[0]));
zend_compile_assign(result, ast, false, type);
return NULL;
default: