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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 2 09:50:28 PDT 2010


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



--- Comment #8 from Ellery Newcomer <ellery-newcomer at 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: -------


More information about the Digitalmars-d-bugs mailing list