1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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.
This commit is contained in:
Ilija Tovilo
2026-02-01 14:13:31 +01:00
parent 6419618f54
commit a01a8e72ac
2 changed files with 20 additions and 1 deletions

View File

@@ -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"
}

View File

@@ -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: