A low-priority idea. As suggested by Andrei the D language can disallow naked instructions composed by a single semicolon: void main() { int x;; // single semicolons not allowed goto END; END:; // single semicolons not allowed // END: {} // OK } (D already disallows single semicolons at the end of for statements, etc, so this can make the language more uniform.)
Does this need a DIP?
I had thought this was an error, but it's just a warning.
No need for a DIP, we should just convert this to an error.
(In reply to Andrei Alexandrescu from comment #3) > No need for a DIP, we should just convert this to an error. If we do this, then we have to special case for(;;). Also it might break an unknown amount of code. At the very least we should have a cost/benefit analysis.
(In reply to uplink.coder from comment #4) > (In reply to Andrei Alexandrescu from comment #3) > > No need for a DIP, we should just convert this to an error. > > If we do this, then we have to special case for(;;). We're in good shape, the semicolons in for are part of the grammar. > Also it might break an unknown amount of code. > At the very least we should have a cost/benefit analysis. The warning has been in there for years. The basic idea is to convert warnings to errors.
(In reply to Andrei Alexandrescu from comment #5) > The warning has been in there for years. The basic idea is to convert > warnings to errors. I just tried : int i;; It compiles just fine without a warning.
Not if you compile with `-w`: ``` C:\Users\Burgos>type test.d void main() { int x;; } C:\Users\Burgos>dmd -w test.d test.d(3): Warning: use '{ }' for an empty statement, not a ';' ```
Poor dlang bot got confused by my initial typo in the commit message (wrong issue referenced), but the commits are pushed to master: https://github.com/dlang/dmd/pull/6886
Today this prints: saa.d(2): Deprecation: use { } for an empty statement, not ; Which is perfectly fine IMHO.