[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-06-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #10 from Walter Bright bugzi...@digitalmars.com 2010-06-01 
23:52:32 PDT ---
http://www.dsource.org/projects/dmd/changeset/514

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854


Ellery Newcomer ellery-newco...@utulsa.edu changed:

   What|Removed |Added

 Attachment #597 is|0   |1
   obsolete||


--- Comment #9 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-04-24 
11:07:19 PDT ---
Created an attachment (id=614)
the patch which I mistakenly put in 3716

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854



--- Comment #7 from Iain Buclaw ibuc...@ubuntu.com 2010-04-02 04:27:27 PDT ---
(In reply to comment #6)
 (In reply to comment #5)
  
  Attached is a patch that resolves the issue. Am not sure that the patch in 
  the
  other bug report is reasonably correct, but hey ho!
  
  Regards
  Iain
 
 Eh? What makes you think it isn't?

Well, from what I can tell, if I were to have the following code excerpt:

int[] a = [1]];

The scan ahead routine will swallow the [1], and since (--brackets == 0),
takes a peek at the last bracket, to which it matches in the if statement and
says 'yep, that is OK'.
In other words, it assumes that whether or not the above line is correct has
already been checked, or will be checked later on during the compile (which I
don't doubt it already has, but at least see it better to have some sort of
sanitisation when checking things).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854



--- Comment #8 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-04-02 
09:50:23 PDT ---
(In reply to comment #7)
  
  Eh? What makes you think it isn't?
 
 Well, from what I can tell, if I were to have the following code excerpt:
 
 int[] a = [1]];
 
 The scan ahead routine will swallow the [1], and since (--brackets == 0),
 takes a peek at the last bracket, to which it matches in the if statement and
 says 'yep, that is OK'.
 In other words, it assumes that whether or not the above line is correct has
 already been checked, or will be checked later on during the compile (which I
 don't doubt it already has, but at least see it better to have some sort of
 sanitisation when checking things).

The scan ahead doesn't swallow anything. It does see only [1] and because
(--brackets == 0) it says I'm going to parse this as ArrayInitializer, which
it does. The next loop (the ArrayInitializer rule) swallows [1], and no more.
Then parseInitializer is done. The function that called parseInitializer
(parseDeclarations or whatever), will expect a semicolon or comma to be the
next token, and when it sees lbracket, it errors.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-04-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854



--- Comment #5 from Iain Buclaw ibuc...@ubuntu.com 2010-04-01 17:43:06 PDT ---
Created an attachment (id=597)
keep track of static array initiliasiser depth

OK, just for clarification.

uint[][] b = [[ 1, 2 ]];   // OK
uint[][] b = [[ 1, 2 ],];  // OK
uint[][] b = [[ 1, 2, ],]; // OK
uint[][] b = [[ 1, 2, ]];  // Error

Why this happens?
The scan ahead loop in parse.c isn't aware of just how deep it has navigated
into the array it is scanning.

First loop, scans the string:
[[ 1, 2, ]]
Second loop, because of the trailing comma, starts another parseInitializer()
call, but this time scanning the string:
[ 1, 2, ]]

Because it reaches end of the scan ahead loop earlier this time, and checking
the next token fails, then treats it as an expression, not an array
initializer.

Attached is a patch that resolves the issue. Am not sure that the patch in the
other bug report is reasonably correct, but hey ho!

Regards
Iain

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-04-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854



--- Comment #6 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-04-01 
18:19:29 PDT ---
(In reply to comment #5)
 
 Attached is a patch that resolves the issue. Am not sure that the patch in the
 other bug report is reasonably correct, but hey ho!
 
 Regards
 Iain

Eh? What makes you think it isn't?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-03-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854


Iain Buclaw ibuc...@ubuntu.com changed:

   What|Removed |Added

 CC||ibuc...@ubuntu.com


--- Comment #4 from Iain Buclaw ibuc...@ubuntu.com 2010-03-21 12:04:34 PDT ---
Paradoxically, the absent of a trailing comma can trigger this error too.

int[][][] a = [[ [1,2],[3,4], ]]; // Error

Whereas:
int[][][] a = [[ [1,2],[3,4], ],]; // OK


Seems like a bug to me, and the patch in bug 3716 resolves this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-02-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 CC||clugd...@yahoo.com.au


--- Comment #1 from Don clugd...@yahoo.com.au 2010-02-25 12:39:25 PST ---
I think this is a duplicate of bug 3716.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-02-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854



--- Comment #2 from Markus Dangl s...@q1cc.net 2010-02-25 12:54:14 PST ---
(In reply to comment #1)
 I think this is a duplicate of bug 3716.

It was named D2 only and does not mention problems with trailing commas, thus i
made it a seperate bug.
I tested the code of #3716 with dmd 1.056 and it worked, so i suppose it really
is a different bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-02-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854


Ellery Newcomer ellery-newco...@utulsa.edu changed:

   What|Removed |Added

 CC||ellery-newco...@utulsa.edu


--- Comment #3 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-02-25 
20:27:36 PST ---
(In reply to comment #2)
 (In reply to comment #1)
  I think this is a duplicate of bug 3716.
 
 It was named D2 only and does not mention problems with trailing commas, thus 
 i
 made it a seperate bug.
 I tested the code of #3716 with dmd 1.056 and it worked, so i suppose it 
 really
 is a different bug.

The trailing commas are deliberate and part of the spec. If you want to
complain about trailing commas, complain that array initializers allow them and
array literal expressions don't.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---