Bug #72754 [Opn]: Compile-time Fatal Error from "[] + 1;" ?
| From: | ryosuke_i_628 at yahoo dot co dot jp | Date: | Fri, 05 Aug 2016 12:46:40 +0000 |
| Subject: | Bug #72754 [Opn]: Compile-time Fatal Error from "[] + 1;" ? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202958@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72754&edit=1
ID: 72754
User updated by: ryosuke_i_628 at yahoo dot co dot jp
Reported by: ryosuke_i_628 at yahoo dot co dot jp
Summary: Compile-time Fatal Error from "[] + 1;" ?
Status: Open
Type: Bug
Package: *General Issues
PHP Version: 7.0.9
Block user comment: N
Private report: N
New Comment:
Although I have no problem with this, it seems to be an unexpected change. If developers have
explicitly changed the feature, there are nothing to say. Sorry and appreciate for your response.
Previous Comments:
------------------------------------------------------------------------
[2016-08-04 11:59:58] nikic@php.net
I'm sorry, could you please be more precise about what the issue is here. Yes, it changed to a
compile-time error... but what of it? Why is this a problem for you?
------------------------------------------------------------------------
[2016-08-04 11:54:02] ryosuke_i_628 at yahoo dot co dot jp
In PHP 5, direct call for __clone() causes E_COMPILE_ERROR. So we should change Compilte-time
E_ERROR into E_COMPILE_ERROR or Runtime E_ERROR.
------------------------------------------------------------------------
[2016-08-04 11:22:13] ryosuke_i_628 at yahoo dot co dot jp
Description:
------------
In PHP 7, "[] + 1;" seems to cause compile-time Fatal Error.
The important thing is that the issue occurrs on "array literal + non-array literal"
expressions. If either opereand gets turned to be a variable, PHP 7 behaves as same as PHP 5.
Test script:
---------------
<?php
exit;
[] + 1;
Expected result:
----------------
No outputs.
Actual result:
--------------
PHP Fatal error: Unsupported operand types in - on line 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72754&edit=1