php-src/Zend/tests/coalesce_assign_optimization.phpt
Nikita Popov 8c4a7f20f5 Fix COPY_TMP live range construction with optimization
The use may be optimized away, leaving us only with the free use.
Also fix off-by-one error in the other optimization case.
2021-11-11 10:35:34 +01:00

21 lines
319 B
PHP

--TEST--
Live range construction should not break if colesce assign branch is optimized away
--FILE--
<?php
function test() {
$a[X] ??= Y;
var_dump($a);
}
function test2(string $b, int $c) {
$a[~$b] ??= $c;
}
define('X', 1);
define('Y', 2);
test();
test2("", 0);
?>
--EXPECT--
array(1) {
[1]=>
int(2)
}