digitalmars.D.bugs - [Issue 3854] New: Error on static initialization of arrays with trailing comma.
- d-bugmail puremagic.com (35/35) Feb 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (10/10) Feb 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (10/11) Feb 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (13/20) Feb 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (14/14) Mar 21 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (27/27) Apr 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (7/13) Apr 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (15/24) Apr 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (12/26) Apr 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (12/12) Apr 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
- d-bugmail puremagic.com (12/12) Jun 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3854
http://d.puremagic.com/issues/show_bug.cgi?id=3854 Summary: Error on static initialization of arrays with trailing comma. Product: D Version: 1.056 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: sky q1cc.net The following code worked in DMD 1.045, but not with 1.056 and i think it should: uint[][] b = [[ 1, 2, ]]; The following code always works, which is odd: uint[] a = [ 1, 2, ]; I assume it is a minor parser bug. Workaround: Omit the last comma. Here is the full code i used: module main; int main(char[][] args) { uint[][] b = [[ 1, 2, ]]; return 0; } And the output of "dmd main.d": main.d(3): expression expected, not ']' main.d(3): comma expected separating array initializers, not ; main.d(4): semicolon expected, not 'return' -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au 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: -------
Feb 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854I 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. is a different bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 Ellery Newcomer <ellery-newcomer utulsa.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ellery-newcomer utulsa.edu 20:27:36 PST ---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: -------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. is a different bug.
Feb 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 Iain Buclaw <ibuclaw ubuntu.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ibuclaw ubuntu.com 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: -------
Mar 21 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 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: -------
Apr 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 18:19:29 PDT ---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 IainEh? What makes you think it isn't? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854Well, 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: -------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 IainEh? What makes you think it isn't?
Apr 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 09:50:23 PDT ---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: -------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).
Apr 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 Ellery Newcomer <ellery-newcomer utulsa.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- obsolete| | 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: -------
Apr 24 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3854 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED 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: -------
Jun 01 2010