xref: /PHP-8.2/Zend/tests/gh12102_3.phpt (revision 748adf18)
1--TEST--
2GH-12102: Incorrect "Cannot use temporary expression in write context" error for BP_VAR_FUNC_ARG
3--FILE--
4<?php
5
6function test() {
7    byVal(C[0]);
8    try {
9        byRef(C[0]);
10    } catch (Error $e) {
11        echo $e->getMessage(), "\n";
12    }
13}
14
15/* Intentionally declared after test() to avoid compile-time checking of ref args. */
16
17const C = ['foo'];
18
19function byVal($arg) {
20    var_dump($arg);
21}
22
23function byRef(&$arg) {
24    var_dump($arg);
25}
26
27test('y');
28
29?>
30--EXPECT--
31string(3) "foo"
32Cannot use temporary expression in write context
33