[php-src] Issue #11320: PHP Fatal error: Cannot use list() as standalone expression
| From: | kubawerlos | Date: | Thu, 25 May 2023 16:48:48 +0000 |
| Subject: | [php-src] Issue #11320: PHP Fatal error: Cannot use list() as standalone expression | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244534@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11320
Author: kubawerlos
### Description
The following code:
```php
<?php
$index = 1;
function getList() { return [2, 3]; }
$a = [$index => list($x, $y) = getList()];
print_r($a);
```
Resulted in this output:
```
PHP Fatal error: Cannot use list() as standalone expression in test.php on line 6
```
But I expected this output instead:
```
Array
(
[1] => Array
(
[0] => 2
[1] => 3
)
)
```
This syntax is [correct since PHP 5.4 up to
8.2](https://github.com/6b7562617765726c6f73/php-syntax/actions/runs/5082311972).
Timeframe: it started to fail yesterday in PHP CS Fixer CI:
- last passed build: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/actions/runs/5070108485
- first failed build: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/actions/runs/5075648935/jobs/9119207560
### PHP Version
8.3.0-dev
### Operating System
_No response_