Bug #69889 [Opn]: Null coalesce operator doesn't work for string offsets

From: Date: Sat, 20 Jun 2015 13:04:08 +0000
Subject: Bug #69889 [Opn]: Null coalesce operator doesn't work for string offsets
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193716@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: laruence@php.net Reported by: me at kelunik dot com Summary: Null coalesce operator doesn't work for string offsets Status: Open Type: Bug Package: *General Issues PHP Version: 7.0.0alpha1 Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#193716) next »