Req #46410 [Opn->Csd]: Assignment does not properly evaluate to reference
| From: | nikic@php.net | Date: | Sun, 12 Oct 2014 14:36:33 +0000 |
| Subject: | Req #46410 [Opn->Csd]: Assignment does not properly evaluate to reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188031@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46410&edit=1
ID: 46410
Updated by: nikic@php.net
Reported by: jbleau at gmail dot com
Summary: Assignment does not properly evaluate to reference
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.2.6
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
2., 3. and 4. will work in PHP 7.
1. does not work and should not work. (Assignments in PHP return rvalues.)
Previous Comments:
------------------------------------------------------------------------
[2008-10-29 04:57:02] jbleau at gmail dot com
Description:
------------
Assignments which should otherwise evaluate to references of the l-value do not properly do so in
some situations, but do in others.
Reproduce code:
---------------
1. echo ($x = 5)--;
2. echo ($x = Array(3))[0];
3. echo ($x = ($y = 3));
I presume this is also related:
4.
function foo(){ return Array(3); }
echo (foo())[0];
Expected result:
----------------
1. 4
2. 3
3. 3
4. 3
Actual result:
--------------
1. Parser chokes on T_DEC
2. Parser chokes on [
3. Works correctly, 3 is assigned to $x and $y and printed.
4. Parser chokes on [
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=46410&edit=1