|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69160 Yield with operator regression
Submitted: 2015-03-02 15:23 UTC Modified: 2015-03-09 11:43 UTC
From: pierre at pcservice dot co dot za Assigned: nikic (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: master-Git-2015-03-02 (Git) OS: ALL
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: pierre at pcservice dot co dot za
New email:
PHP Version: OS:


 [2015-03-02 15:23 UTC] pierre at pcservice dot co dot za
When yielding using + or - operator, the value is returned before the operation is performed. In previous versions of PHP (>= 5.5 && < 7.0-dev) the operation was first performed on the value before it was return.

Test script:
function a () {
    echo yield + 3;

$a = a();

Expected result:

Actual result:


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-04 06:25 UTC]
-Assigned To: +Assigned To: nikic
 [2015-03-07 19:38 UTC]
This isn't a bug: It's now handled as unary operator due to yield operator having right associativity with high precedence and not requiring parenthesis anymore.

It is basically a BC break caused by AST RFC and should be noted as such in UPGRADING under Backward Incompatible Changes.

For this particular case you now either have to put the operand before the yield:
echo 3 + yield;

Or put parenthesis around it:
echo (yield) + 3;
 [2015-03-09 11:43 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 09:05:45 2022 UTC