Skip to content

PHP Fatal error: Cannot use list() as standalone expression #11320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kubawerlos opened this issue May 25, 2023 · 1 comment · Fixed by #11322
Closed

PHP Fatal error: Cannot use list() as standalone expression #11320

kubawerlos opened this issue May 25, 2023 · 1 comment · Fixed by #11322

Comments

@kubawerlos
Copy link

Description

The following code:

<?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.

Timeframe: it started to fail yesterday in PHP CS Fixer CI:

PHP Version

8.3.0-dev

Operating System

No response

@nielsdos
Copy link
Member

This regressed in commit 1c733c8 /cc @iluuu1994

@iluuu1994 iluuu1994 self-assigned this May 25, 2023
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue May 25, 2023
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue May 26, 2023
iluuu1994 added a commit that referenced this issue May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants