php-src/Zend/tests/bug71030.phpt
Nikita Popov d0a56f707f Fixed bug #71030
Make sure to always fetch the RHS of a list assignment first, instead
of special casing known self-assignments, which will not detect cases
using references correctly.

As a side-effect, it is no longer possible to do something like
byRef(list($x) = $y). This worked by accident previously, but only
if $y was a CV and the self-assignment case did not trigger.
However it shouldn't work for the same reason that byRef($x = $y)
doesn't. Conversely byRef(list(&$x) = $y) and byRef($x =& $y)
continue to be legal.
2019-05-09 14:31:39 +02:00

29 lines
354 B
PHP

--TEST--
Bug #71030: Self-assignment in list() may have inconsistent behavior
--FILE--
<?php
function test1() {
$a = [1, 2];
$c =& $a;
list($c, $b) = $a;
var_dump($a, $b);
}
function test2() {
$a = [1, 2];
$_a = "a";
list($$_a, $b) = $a;
var_dump($a, $b);
}
test1();
test2();
?>
--EXPECT--
int(1)
int(2)
int(1)
int(2)