hhvm
hhvm copied to clipboard
list() bug (from phpcompiler test suite)
$info = array('coffee', 'brown', 'caffeine');
list($info[2], $info[1], $info[0]) = $info;
// it looks like it reverses the order, but it doesnt. It first overwrites
// $info[0], then later overwrites $info[2] with the value already copied
// from $info[2]
var_dump ($info);
I don't know if anyone cares about this, lol.
[root@ocportal phc]# php test.php
array(3) {
[0]=>
string(8) "caffeine"
[1]=>
string(5) "brown"
[2]=>
string(8) "caffeine"
}
[root@ocportal phc]# sudo $HPHP_HOME/src/hphpi/hphpi -f test.php
array(3) {
[0]=>
string(8) "caffeine"
[1]=>
string(5) "brown"
[2]=>
string(6) "coffee"
}
Personally, I'm inclined to file this under "undefined behavior" as the variables is being modified at the same time that it's being read.
I'm going to keep it open for now and discuss with others.
HPHPi was removed from the code base in June 2012. We recommend that developers using HPHPi upgrade to HHVM.
HHVM matches Zend's behavior for your test case.