[php-src] Issue #14135: Unpacking via list() produces NULLs in foreach
| From: | swaro32 | Date: | Sat, 04 May 2024 15:16:11 +0000 |
| Subject: | [php-src] Issue #14135: Unpacking via list() produces NULLs in foreach | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246855@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14135
Author: swaro32
### Description
Hi! I've encountered this NULL bug
```php
$arr = ["definitely not array", [1,2]];
foreach ($arr as [$a,$b]) // same as list($a,$b)
{
var_dump($a,$b); // NULL NULL 1 2
}
```
Resulted in this output **_without_** any notices/warnings/errors/etc...:
```
NULL
NULL
int(1)
int(2)
```
It seems that this bug is in every single PHP version that supports the syntax (and list()
unpackings) above.
Also works with ints, floats, booleans, nulls.
3v4l: https://3v4l.org/M754F#v8.3.6
### PHP Version
PHP 8.1.0 (cli)
### Operating System
Windows 10