Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 29, 2008 [Issue 2477] New: Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
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@digitalmars.com ReportedBy: wbaxter@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. -- |
December 01, 2008 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 smjg@iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg@iname.com Keywords| |diagnostic, spec ------- Comment #1 from smjg@iname.com 2008-11-30 19:20 ------- The problem is that the spec is inconsistent. In the first case, it's not an array literal, but an array initializer. ArrayInitializer: [ ] [ ArrayMemberInitializations ] ArrayMemberInitializations: ArrayMemberInitialization ArrayMemberInitialization , ArrayMemberInitialization , ArrayMemberInitializations versus ArrayLiteral: [ ArgumentList ] ArgumentList: AssignExpression AssignExpression , ArgumentList Making these consistent is technically an enhancement request rather than a bug. I nearly set this to enhancement, but the second issue (repetition of the error message) qualifies as a bug IMO. -- |
December 01, 2008 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 ------- Comment #2 from wbaxter@gmail.com 2008-11-30 19:38 ------- Thanks for the spec digging, Stewart. So I see three options: 1) change the ArrayMemberInitializations production to: ArrayMemberInitializations: ArrayMemberInitialization ArrayMemberInitialization , ArrayMemberInitializations (get rid of the trailing comma case for initializations) 2) change the ArrayLiteral productions to ArrayLiteral: [ ArrayLiteralMemberList ] ArrayLiteralMemberList: AssignExpression AssignExpression , AssignExpression , ArrayLiteralMemberList 3) Just make all argument lists have an optional trailing comma. This is based on the thinking that if allowing a trailing comma is a nice feature for arrays, then why not general argument lists (which can be used as general array constructors with typesafe variadic A[]... style parameters.)? ArgumentList: AssignExpression AssignExpression , AssignExpression , ArgumentList I vote for #2. -- |
July 18, 2009 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 Brian Kropf <brian.kropf@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |brian.kropf@gmail.com --- Comment #3 from Brian Kropf <brian.kropf@gmail.com> 2009-07-17 18:24:47 PDT --- I'd originally submitted this on the ldc bugtracker and got forwarded here (since it is using the dmd front-end). Here's a bit more info on the issue: When using sabledd generated code, I'm seeing an error with ldc that was not present when I used gdc. It boils down to ldc not accepting only part of the endings of array initializers having commas. The following minimal test case does not build successfully on ldc x64 (but it will if you add a comma to the end of the second array initializer (like '[ 4, 5, 6, ],'). Curiously enough it also builds cleanly if I remove the commas after the 3 and the 6 in the example. test.d: int arr[][] = [ [ 1, 2, 3, ], [ 4, 5, 6, ] ]; int main(char[][] args) { return 0; } Error output: test.d(7): expression expected, not ']' test.d(7): comma expected separating array initializers, not ; test.d(9): semicolon expected, not 'int' Error: Command failed, aborting. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 30, 2010 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 Aziz Köksal <aziz.koeksal@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aziz.koeksal@gmail.com --- Comment #4 from Aziz Köksal <aziz.koeksal@gmail.com> 2010-04-30 06:54:22 PDT --- I agree, ArgumentLists, ArrayLiterals etc. should allow a trailing comma, just like ParameterLists or enums. Fixing this should be possible in 6 to 10 lines of code. Why is this issue still open? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 30, 2010 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #5 from Don <clugdbug@yahoo.com.au> 2010-04-30 07:18:03 PDT --- (In reply to comment #4) > I agree, ArgumentLists, ArrayLiterals etc. should allow a trailing comma, just like ParameterLists or enums. > > Fixing this should be possible in 6 to 10 lines of code. Why is this issue still open? Because there are over 1000 open bugs, and nearly all of them are more important than this one. Make a patch for it, if you care about it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 30, 2010 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 --- Comment #6 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2010-04-30 08:49:05 PDT --- Created an attachment (id=615) allow trailing commas in various places modifications for ArrayLiteral, Arguments, TemplateParameterList, and TemplateArguments. I haven't tested it too heavily, but the simple stuff works. There might be latent trouble in the ambiguity between ArrayInitializer and ArrayLiteral (aside from what's already present), as I'm not well versed in what happens past the parser. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 30, 2010 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 --- Comment #7 from Aziz Köksal <aziz.koeksal@gmail.com> 2010-04-30 09:05:23 PDT --- Don, I know it's not extremely important. I care about it, but I can't make patches for the DMD front- or back-end. Not because I don't want to, but because I'm working on a similar project; my own D compiler, remember? :-) Ellery, thanks for taking care of this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 30, 2010 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 --- Comment #8 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2010-04-30 10:02:04 PDT --- (In reply to comment #7) > Don, I know it's not extremely important. I care about it, but I can't make patches for the DMD front- or back-end. Not because I don't want to, but because I'm working on a similar project; my own D compiler, remember? :-) > Come to think of it, so am I, or I was. I don't care much about the licensing, though. Or releasing it, if I ever finish it. > Ellery, thanks for taking care of this. Only needed to change 4 lines :) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 28, 2010 [Issue 2477] Trailing comma in array literal sometimes accepted, sometimes not | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2477 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com Version|1.037 |D2 OS/Version|Windows |All Severity|normal |enhancement --- Comment #9 from Walter Bright <bugzilla@digitalmars.com> 2010-08-28 13:19:43 PDT --- Since this changes the language, I'm going to do it for D2 only and mark it as an enhancement request. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation