Bug 200 – Statement *must* follow label

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-06-16T15:11:00Z
Last change time
2014-02-15T13:21:09Z
Assigned to
bugzilla
Creator
ericanderton

Comments

Comment #0 by ericanderton — 2006-06-16T15:11:10Z
This one is pretty simple. The parser seems to think that the only valid way to use a label is if a statement directly follows it. But shouldn't a label be valid all by itself, if its the last line of a scope? void main(){ x: } test.d(3): found '}' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement test.d(3): found 'EOF' instead of statement The workaround for this one is dead simple: just use a ';' right after the label. IMO, that doesn't look like valid code. void main(){ x: ; }
Comment #1 by smjg — 2006-06-19T09:42:53Z
The spec gives: LabelledStatement: Identifier ':' Statement i.e. a label prefixes a statement - it doesn't act as a statement by itself. (In reply to comment #0) > The workaround for this one is dead simple: just use a ';' right after the > label. IMO, that doesn't look like valid code. Indeed, it isn't according to the spec, and for good reasons. Use an empty BlockStatement instead. void main() { x: {} }
Comment #2 by bugzilla — 2006-06-30T20:30:50Z
Fixed DMD 0.162 (changed spec to allow ';' as empty statement after label)