Bug #75426 [Opn]: "Cannot use empty array elements" reports wrong position
Edit report at https://bugs.php.net/bug.php?id=75426&edit=1
ID: 75426
Updated by: nikic@php.net
Reported by: cweiske@php.net
Summary: "Cannot use empty array elements" reports wrong
position
Status: Open
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.2.0RC4
Block user comment: N
Private report: N
New Comment:
I've committed a partial fix for this issue at https://github.com/php/php-src/commit/73596c56e7905ce5b7c4f15d551361ee744cad0c.
It doesn't actually change anything for the case shown here, but if the array is larger, it
will now point to the element before the stray comma.
Previous Comments:
------------------------------------------------------------------------
[2017-11-23 11:06:27] andrew dot nester dot dev at gmail dot com
Thanks for pointing this issue! I've just added CR implementing this.
------------------------------------------------------------------------
[2017-10-24 12:20:15] cweiske@php.net
Description:
------------
If there is a syntax error because there are two consecutive commas in an array, a fatal error is
reported:
PHP Fatal error: Cannot use empty array elements in arrays in file.php on line 3
The problem is that the line reported is the start of the array definition, not the line at which
the error actually is.
This makes it very hard to debug array definitions of 100 lines length.
See https://3v4l.org/Ek6pJ and https://3v4l.org/WJUbZ
Test script:
---------------
<?php
$a = [
1,
,
3
];
Expected result:
----------------
Line 4 should be reported.
Actual result:
--------------
Line 3 is reported.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75426&edit=1
Thread (3 messages)