From a01a8e72acdf3cba61abe51b7408968dcc81da09 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sun, 1 Feb 2026 14:13:31 +0100 Subject: [PATCH] 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. --- Zend/tests/gh20628_005.phpt | 20 ++++++++++++++++++++ Zend/zend_compile.c | 1 - 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/gh20628_005.phpt 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-- + '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: