Bug #72754 [Opn]: Compile-time Fatal Error from "[] + 1;" ?

From: Date: Thu, 04 Aug 2016 11:59:59 +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-202921@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
 Updated by:         nikic@php.net
 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:

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?


Previous Comments:
------------------------------------------------------------------------
[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


Thread (5 messages)

« previous php.bugs (#202921) next »