Bug #69891 [Asn->Csd]: Unexpected array comparison result
| From: | nikic@php.net | Date: | Sat, 20 Jun 2015 15:36:59 +0000 |
| Subject: | Bug #69891 [Asn->Csd]: Unexpected array comparison result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193725@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69891&edit=1
ID: 69891
Updated by: nikic@php.net
Reported by: colinodell at gmail dot com
Summary: Unexpected array comparison result
-Status: Assigned
+Status: Closed
Type: Bug
Package: Arrays related
Operating System: Ubuntu 14.04.1 LTS 3.13.0-34-gen
PHP Version: 7.0Git-2015-06-20 (Git)
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=e8217a2727b20997e6f39d59c44a20cc61d7e6c7
Log: Fix bug #69891
Previous Comments:
------------------------------------------------------------------------
[2015-06-20 13:58:15] colinodell at gmail dot com
Description:
------------
Using the comparison (spaceship) operator on arrays with different lengths produces unexpected
results. It seems to be returning the difference in length instead of restricting the output to -1,
0, or 1.
I am using Zend's Debian nightly build: PHP 7.0.0-dev (cli) (built: Jun 19 2015 19:09:04)
Test script:
---------------
// Here's a direct example from the RFC, which says this
// should evaluate to 1. However, I get 3 instead:
echo [1, 2, 3] <=> [];
// Here are some other examples:
echo [1, 2, 3, 4, 5] <=> []; // 5
echo [] <=> [1, 2, 3, 4, 5]; // -5
echo [1, 2, 3, 4, 5] <=> [1]; // 4
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69891&edit=1