Skip to content

Commit a01a8e7

Browse files
committed
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.
1 parent 6419618 commit a01a8e7

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Zend/tests/gh20628_005.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Failed assertion for assignment in expression context
3+
--CREDITS--
4+
Matteo Beccati (mbeccati)
5+
--FILE--
6+
<?php
7+
8+
function foo() {
9+
return ['bar' => 'baz'];
10+
}
11+
12+
var_dump(($v = foo())['bar'], $v);
13+
14+
?>
15+
--EXPECT--
16+
string(3) "baz"
17+
array(1) {
18+
["bar"]=>
19+
string(3) "baz"
20+
}

Zend/zend_compile.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12303,7 +12303,6 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
1230312303
zend_compile_assign_ref(result, ast, type);
1230412304
return NULL;
1230512305
case ZEND_AST_ASSIGN:
12306-
ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_ARRAY && zend_propagate_list_refs(ast->child[0]));
1230712306
zend_compile_assign(result, ast, false, type);
1230812307
return NULL;
1230912308
default:

0 commit comments

Comments
 (0)