yield without value in reference generator function does not create notice
Open
Nobody has claimed this yet.
Bug
Category: Generators
Status: Verified
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
error_reporting(E_ALL);
function &y()
{
yield null; // warning
yield; // no warning
}
foreach (y() as &$y);
Resulted in this output:
PHP Notice: Only variable references should be yielded by reference in /home/user10/test.php on line 5
But I expected this output instead:
PHP Notice: Only variable references should be yielded by reference in /home/user10/test.php on line 5
PHP Notice: Only variable references should be yielded by reference in /home/user10/test.php on line 6
PHP Version
PHP 8.2.24 (cli) (built: Sep 27 2024 04:16:10) (NTS)
Operating System
Debian GNU/Linux 12 (bookworm)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reference generator example on PHP 8.2.24 with E_ALL enabled, then trace how the two yield forms are handled. Done means the value-less yield emits the same notice as yield null, with regression coverage for both lines.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100