[Issue 2477] New: Trailing comma in array literal sometimes accepted, sometimes not

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 28 21:04:30 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2477

           Summary: Trailing comma in array literal sometimes accepted,
                    sometimes not
           Product: D
           Version: 1.037
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: wbaxter at gmail.com


void main() {
    int[] data = [1,2,3,];  // OK

    data = [ 1,2,3, ];  // fails
/+
// error messages
trailcomma.d(20): found ';' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
trailcomma.d(29): found 'EOF' when expecting ','
+/
}

The repetition of the EOF error message 20 times is also rather odd.

I don't know if trailing comma is spec'ed as being allowed or not (I much
prefer allowing it), but either way it should be consistent.


-- 



More information about the Digitalmars-d-bugs mailing list