php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72754 Compile-time Fatal Error from "[] + 1;" ?
Submitted: 2016-08-04 11:22 UTC Modified: 2016-08-05 22:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ryosuke_i_628 at yahoo dot co dot jp Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.9 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ryosuke_i_628 at yahoo dot co dot jp
New email:
PHP Version: OS:

 

 [2016-08-04 11:22 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-04 11:54 UTC] 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:59 UTC] 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-05 12:46 UTC] ryosuke_i_628 at yahoo dot co dot jp
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.
 [2016-08-05 22:22 UTC] kalle@php.net
-Status: Open +Status: Not a bug
 [2016-08-05 22:22 UTC] kalle@php.net
Gonna mark it as NaB
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 12:01:36 2025 UTC