ID: 42440
Updated by: [EMAIL PROTECTED]
Reported By: romain dot tartiere at healthgrid dot org
Status: Bogus
Bug Type: Arrays related
Operating System: GNU/Linux
PHP Version: 5.2.3
New Comment:
It's a Duplicate of bug #23022
Previous Comments:
------------------------------------------------------------------------
[2007-08-27 12:42:56] romain dot tartiere at healthgrid dot org
Thank you for your personalised answer and taking time to read and
understand my bug report.
This is obviously a bug: even the "array(1,2,3)[1]" expression cannot
be parsed by PHP!
Maybe it is just a LALR parser mistake like...
stuff: [...]
| variable '[' expression ']'
... instead of ...
stuff: [...]
| expression '[' expression ']'
Sorry for being rude, but your copy-paste-reply make me feel my problem
has been underestimated by an inexperienced person. But maybe I am
wrong, then just prove me that what I am talking about is nonsense...
According to me, if I can't do "a[i]" but can do "b = a; b[i]", there
is something wrong.
------------------------------------------------------------------------
[2007-08-27 10:22:54] [EMAIL PROTECTED]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2007-08-27 10:00:01] romain dot tartiere at healthgrid dot org
Description:
------------
When using a function that returns an array, the parser is not apple to
correctly parse the expression and assign the n'th element to a variable
Reproduce code:
---------------
<?php
function foo() {
return array(1, 2, 3);
}
echo foo()[1]; # <<<
?>
Expected result:
----------------
2 (second element of the array)
Actual result:
--------------
Parse error: syntax error, unexpected '[', expecting ',' or ';'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42440&edit=1