digitalmars.D.bugs - [Issue 327] New: Compiler accepts ';' by itself as a statement
- d-bugmail puremagic.com (42/42) Sep 06 2006 http://d.puremagic.com/issues/show_bug.cgi?id=327
- d-bugmail puremagic.com (10/10) Nov 15 2006 http://d.puremagic.com/issues/show_bug.cgi?id=327
- d-bugmail puremagic.com (5/5) Nov 15 2006 http://d.puremagic.com/issues/show_bug.cgi?id=327
- d-bugmail puremagic.com (9/9) Nov 18 2006 http://d.puremagic.com/issues/show_bug.cgi?id=327
- d-bugmail puremagic.com (13/13) Nov 19 2006 http://d.puremagic.com/issues/show_bug.cgi?id=327
- d-bugmail puremagic.com (6/7) Nov 19 2006 http://d.puremagic.com/issues/show_bug.cgi?id=327
- d-bugmail puremagic.com (16/16) Nov 19 2006 http://d.puremagic.com/issues/show_bug.cgi?id=327
- Stewart Gordon (14/34) Nov 19 2006 Regardless of the obviousness that leaving it specified this way was a
- d-bugmail puremagic.com (12/12) Jul 26 2009 http://d.puremagic.com/issues/show_bug.cgi?id=327
http://d.puremagic.com/issues/show_bug.cgi?id=327 Summary: Compiler accepts ';' by itself as a statement Product: D Version: 0.165 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: smjg iname.com The following code compiles without error: ---------- void main() { ; } ---------- and produces a program that does nothing. Nothing in the D spec allows a semicolon on its own to be used as a statement. Nonetheless, the current compiler allows it. It has, however, made exceptions for certain control structures, e.g. it rejects if (...) ; for (...) ; while allowing some other similar forms. The language would gain nothing by allowing ';' as a statement in any context. In C, it may have had its uses in conjunction with preprocessor macros. But in D, which has no macro preprocessor, no such use cases exist. Moreover, it is much simpler to disallow such a useless statement form altogether than to let it through and then catch a handful of specific cases. There was once a specific exception, to the effect of LabelledStatement: Identifier ':' Statement Identifier ':' ';' but this has since disappeared from the spec. But if for any reason this is ever reinstated, then implementing it explicitly would still be a lot simpler than the mess things are in at the moment. Existing DStress testcases: http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_06_A.d et seq. --
Sep 06 2006
http://d.puremagic.com/issues/show_bug.cgi?id=327 lio lunesu.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |minor Fixing this would break goto labels at the end of a function. These labels should now be followed by a single colon, since they label a statement, even an empty one. I'm setting severity to minor. --
Nov 15 2006
http://d.puremagic.com/issues/show_bug.cgi?id=327 Please clarify. Why do you feel that the explicit solution I've clearly given for the LabelledStatement issue won't work? --
Nov 15 2006
http://d.puremagic.com/issues/show_bug.cgi?id=327 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Updated the spec to allow this. --
Nov 18 2006
http://d.puremagic.com/issues/show_bug.cgi?id=327 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | Why won't you tell us why? And even if one were to accept this change, I don't consider it fixed at all, because the compiler is still accepting it even in some cases where the design of D is to forbid it. See DStress testcases ExpressionStatement_07_* and ExpressionStatement_08_*. --
Nov 19 2006
http://d.puremagic.com/issues/show_bug.cgi?id=327Why won't you tell us why?I should've replied to your mention on the newsgroup of case and default statements before I wrote that. Well, I have now. --
Nov 19 2006
http://d.puremagic.com/issues/show_bug.cgi?id=327 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID Both DebugStatement and VersionStatement allow a ';' as a statement, as both have Statement in the grammar, and Statement includes ';'. In other words, this is not a bug as the spec matches the implementation. If you want to change it, it should be marked as an enhancement request, not a bug. As to why allow empty statements, 1) such are common in C like languages and are expected to be there and 2) they are 'boundary' or 'degenerate' cases and can be handy to have as markers, placeholders, or to just make it easier for programs that generate source code as output. They don't hurt anything. --
Nov 19 2006
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=327 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID Both DebugStatement and VersionStatement allow a ';' as a statement, as both have Statement in the grammar, and Statement includes ';'. In other words, this is not a bug as the spec matches the implementation. If you want to change it, it should be marked as an enhancement request, not a bug.Regardless of the obviousness that leaving it specified this way was a slip-up?As to why allow empty statements, 1) such are common in C like languages and are expected to be thereExpected by whom?and 2) they are 'boundary' or 'degenerate' cases and can be handy to have as markers, placeholders, or to just make it easier for programs that generate source code as output. They don't hurt anything.Hmm.... Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Nov 19 2006
http://d.puremagic.com/issues/show_bug.cgi?id=327 Stewart Gordon <smjg iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |FIXED The INVALID resolution was due to a mistake in the spec that has since been fixed. And the original issue was fixed by changing the spec. Reverting resolution. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 26 2009