Bug #69160 [Asn->Csd]: Yield with operator regression

From: Date: Mon, 09 Mar 2015 11:43:33 +0000
Subject: Bug #69160 [Asn->Csd]: Yield with operator regression
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191266@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69160&edit=1 ID: 69160 Updated by: nikic@php.net Reported by: pierre at pcservice dot co dot za Summary: Yield with operator regression -Status: Assigned +Status: Closed 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: UPGRADING note added in https://github.com/php/php-src/commit/2f156c61f19a889c8ed39fe8eb3b3220555db647. Previous Comments: ------------------------------------------------------------------------ [2015-03-07 19:38:56] bwoebi@php.net 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-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

« previous php.bugs (#191266) next »