Bug 13363 – DMD accepts bodyless if statement

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-22T21:58:30Z
Last change time
2021-09-08T14:07:15Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Orvid King

Comments

Comment #0 by blah38621 — 2014-08-22T21:58:30Z
DMD currently accepts the following code: IRQualifiedName parseQualifiedName() { IRQualifiedName current; do { if((tok)) AfterProc: } while((tok)) return current; }
Comment #1 by yebblies — 2014-08-23T15:45:35Z
That should be the same as this: if ((tok)) AfterProc: {} It's not particularly useful, but what's wrong with it?
Comment #2 by blah38621 — 2014-08-23T17:16:05Z
It's the same as that, yes, but there is no actual statement, nor are there any curly brackets to denote an empty statement was intended. I believe that if the behaviour was actually intended, the curly brackets should be required, and that this form should produce an error.
Comment #3 by dkorpel — 2021-09-08T14:07:15Z
(In reply to Orvid King from comment #2) > but there is no actual statement There is, it's called a `LabeledStatement` in the grammar.