Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 07, 2011 [Issue 5953] New: Too many trailing commas are accepted | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5953 Summary: Too many trailing commas are accepted Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: minor Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-05-07 16:28:09 PDT --- Accepting an extra trailing comma is acceptable, but this looks excessive (this compiles and runs with no errors, DMD 2.053 beta): void main() { auto a = [,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]; assert(a.length == 0); } As in Python I suggest to accept only one extra trailing comma: >>> a = [1] >>> a = [1,] >>> a = [1,,] File "<stdin>", line 1 a = [1,,] ^ SyntaxError: invalid syntax -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 08, 2011 [Issue 5953] Too many trailing commas are accepted | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5953 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm@gmail.com --- Comment #1 from kennytm@gmail.com 2011-05-07 23:51:21 PDT --- Please don't use Python to say a D syntax is invalid. Use the D spec or TDPL. -------- In the D spec an array literal follows the rule: ArrayLiteral: '[' ArgumentList ']' ArgumentList: AssignExpression AssignExpression ',' AssignExpression ',' ArgumentList and an AssignExpression cannot be empty, so '[1,,]' should be rejected. (BTW this rule doesn't handle '[]' at all.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 08, 2011 [Issue 5953] Too many trailing commas are accepted | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5953 --- Comment #2 from bearophile_hugs@eml.cc 2011-05-08 03:39:56 PDT --- (In reply to comment #1) > Please don't use Python to say a D syntax is invalid. Use the D spec or TDPL. I feel free to show what's the design of other languages, if they are a good example. > and an AssignExpression cannot be empty, so '[1,,]' should be rejected. OK. So it's not a design problem, just an implementation issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 08, 2011 [Issue 5953] Too many trailing commas are accepted | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5953 --- Comment #3 from kennytm@gmail.com 2011-05-08 04:40:20 PDT --- (In reply to comment #2) > (In reply to comment #1) > > Please don't use Python to say a D syntax is invalid. Use the D spec or TDPL. > > I feel free to show what's the design of other languages, if they are a good example. > Yes, but with the 'accept-invalid' tag I think that you want to say [,,,,,,,,,,,,,,,,,,] is invalid because it is invalid in Python. Sorry for misinterpreting. > > > and an AssignExpression cannot be empty, so '[1,,]' should be rejected. > > OK. So it's not a design problem, just an implementation issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 31, 2011 [Issue 5953] Too many trailing commas are accepted | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5953 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2011-08-31 00:36:53 PDT --- https://github.com/D-Programming-Language/dmd/commit/ba4da917ed6b79fc896a21cec91a0de1a04128cb https://github.com/D-Programming-Language/dmd/commit/fc0bbd3afba6e5f878fecc8a029f437b1df51e41 -- 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