mirror of
https://github.com/php/php-src.git
synced 2024-12-16 05:15:03 +08:00
d0a56f707f
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.
29 lines
354 B
PHP
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)
|