Re: Needs Feedback - Yield without value in reference generator function does not create notice
| From: | aggelos bellos | Date: | Wed, 27 Nov 2024 17:41:37 +0000 |
| Subject: | Re: Needs Feedback - Yield without value in reference generator function does not create notice | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-126071@lists.php.net to get a copy of this message | ||
>
> > A notice would be consistent with what happens with: `function &f() {
> return; }; f();`. But don’t add new notices in patch releases, otherwise
> you may break without warning a non-trivial amount of code that conflates
> notices with fatal errors. The bug is not serious enough to warrant such a
> risk.
>
But isn't a bug that the notice is missing in the first place?
In my opinion, whether it should be deprecated is not a separate
> question, but the one we should answer first. If we're not going to
> deprecate/remove the auto-conversion to a reference, we may as well drop
> the notice altogether, instead of adding a further notice.
>
Hmm I am not exactly sure if I agree with you. Whatever we decide, it will
happen in a new version. It feels right to fix the current supported
versions.
Regarding the deprecation decision, I checked the RFC
https://wiki.php.net/rfc/generators and I found
this line:
*Only generators specifying the & modifier can be iterated by ref. If you
> try to iterate a non-ref generator by-ref an E_ERROR is thrown.*
Correct me if I am wrong, but this phrase refers to our case. If I
understand this correctly it should normally throw an E_ERROR so we should
continue perhaps with the deprecation? Other than this, I don't have a
strong opinion on if we should deprecate or not this case.