Bug #69889 [Asn->Csd]: Null coalesce operator doesn't work for string offsets
| From: | nikic@php.net | Date: | Sat, 20 Jun 2015 13:12:02 +0000 |
| Subject: | Bug #69889 [Asn->Csd]: Null coalesce operator doesn't work for string offsets | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193717@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69889&edit=1
ID: 69889
Updated by: nikic@php.net
Reported by: me at kelunik dot com
Summary: Null coalesce operator doesn't work for string
offsets
-Status: Assigned
+Status: Closed
Type: Bug
Package: *General Issues
PHP Version: 7.0.0alpha1
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9fa70dbd29f91c9ae9360f19c63ada18268f5b17
Log: Fixed bug #69889
Previous Comments:
------------------------------------------------------------------------
[2015-06-20 13:04:07] laruence@php.net
the problem is foo[5] returns a empty string, later in ZEND_COALESCE operands, it have no idea it
whether it is a valid return..
instead of change uninitlized offset from empty string to IS_NULL(BC break?), we could also
introduce a CG(error_empty_string) use in such case..
thanks
------------------------------------------------------------------------
[2015-06-20 12:16:15] me at kelunik dot com
Description:
------------
http://3v4l.org/lsoFA
Test script:
---------------
<?php
$foo = "test";
var_dump($foo[0] ?? "default");
var_dump($foo[5] ?? "default");
var_dump(isset($foo[5]) ? $foo[5] : "default");
Expected result:
----------------
string(1) "t"
string(7) "default"
string(7) "default"
Actual result:
--------------
string(1) "t"
string(0) ""
string(7) "default"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69889&edit=1