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

From: Date: Tue, 24 Oct 2017 12:20:16 +0000
Subject: Bug #75426 [NEW]: "Cannot use empty array elements" reports wrong position
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212274@lists.php.net to get a copy of this message
From:             cweiske
Operating system: 
PHP version:      7.2.0RC4
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:"Cannot use empty array elements" reports wrong position

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 bug report at https://bugs.php.net/bug.php?id=75426&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=75426&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=75426&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=75426&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=75426&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=75426&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=75426&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=75426&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=75426&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=75426&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=75426&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=75426&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=75426&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=75426&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75426&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=75426&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=75426&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=75426&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75426&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=75426&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=75426&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#212274) next »