Bug #67750 [NEW]: Subscript Operator claims empty brackets invalid for string
| From: | ralph-bugsphpnet at inputplus dot co dot uk | Date: | Sat, 02 Aug 2014 16:16:45 +0000 |
| Subject: | Bug #67750 [NEW]: Subscript Operator claims empty brackets invalid for string | ||
| Groups: | php.standards | ||
| Request: | Send a blank email to standards-+get-271@lists.php.net to get a copy of this message | ||
From: ralph-bugsphpnet at inputplus dot co dot uk
Operating system:
PHP version: Irrelevant
Package: PHP Language Specification
Bug Type: Bug
Bug description:Subscript Operator claims empty brackets invalid for string
Description:
------------
https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#subscript-operator
says
*expression* can be omitted only if *subscript-expression* is used
in a
modifiable-lvalue context and *postfix-expression* does not
designate a
string.
Yet this is valid:
$a = ""; $a[] = "y"; var_dump($a);
I've omitted expression, postfix-expression is a string, just an empty
one.
The result is array("y"); the original empty string disappears.
See http://3v4l.org/vg7Oe for more.
Test script:
---------------
<?php
$a = ""; $a[] = "y"; var_dump($a);
$b = "x"; $b[] = "y"; var_dump($b);
--
Edit bug report at https://bugs.php.net/bug.php?id=67750&edit=1
--