Bug #75426 [Com]: "Cannot use empty array elements" reports wrong position

From: Date: Thu, 23 Nov 2017 11:06:28 +0000
Subject: Bug #75426 [Com]: "Cannot use empty array elements" reports wrong position
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212690@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75426&edit=1

 ID:                 75426
 Comment by:         andrew dot nester dot dev at gmail dot com
 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:

Thanks for pointing this issue! I've just added CR implementing this.


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

« previous php.bugs (#212690) next »