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)