Bug #69160 [Asn]: Yield with operator regression
Edit report at https://bugs.php.net/bug.php?id=69160&edit=1
ID: 69160
Updated by: bwoebi@php.net
Reported by: pierre at pcservice dot co dot za
Summary: Yield with operator regression
Status: Assigned
Type: Bug
Package: Unknown/Other Function
Operating System: ALL
PHP Version: master-Git-2015-03-02 (Git)
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
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;
Previous Comments:
------------------------------------------------------------------------
[2015-03-02 15:23:56] pierre at pcservice dot co dot za
Description:
------------
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();
$a->send(42);
Expected result:
----------------
45
Actual result:
--------------
42
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69160&edit=1
Thread (3 messages)