mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
748adf18fc
Fixes GH-12102 Closees GH-12140
44 lines
640 B
PHP
44 lines
640 B
PHP
--TEST--
|
|
GH-12102: Incorrect "Cannot use temporary expression in write context" error for BP_VAR_FUNC_ARG
|
|
--FILE--
|
|
<?php
|
|
|
|
function test() {
|
|
global $ref;
|
|
byVal(getRef()[0]);
|
|
var_dump($ref);
|
|
byRef(getRef()[0]);
|
|
var_dump($ref);
|
|
}
|
|
|
|
/* Intentionally declared after test() to avoid compile-time checking of ref args. */
|
|
|
|
function &getRef() {
|
|
global $ref;
|
|
$ref = [];
|
|
return $ref;
|
|
}
|
|
|
|
function byVal($arg) {
|
|
$arg[] = 42;
|
|
}
|
|
|
|
function byRef(&$arg) {
|
|
$arg[] = 42;
|
|
}
|
|
|
|
test();
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Warning: Undefined array key 0 in %s on line %d
|
|
array(0) {
|
|
}
|
|
array(1) {
|
|
[0]=>
|
|
array(1) {
|
|
[0]=>
|
|
int(42)
|
|
}
|
|
}
|