[Issue 200] New: Statement *must* follow label

pragma pragma_member at pathlink.com
Fri Jun 16 16:05:25 PDT 2006


In article <e6v4p9$c5f$1 at digitaldaemon.com>, Frits van Bommel says...
>
>d-bugmail at puremagic.com wrote:
>> 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:
>> }
>
>[snip]
>
>> The workaround for this one is dead simple: just use a ';' right after the
>> label.  IMO, that doesn't look like valid code.
>
>Or, you know, you could just use "return" instead of "goto x" :P

Not always. :)

The example in the bug report is merely the most simple case for Walter's sake
Here's a real-world example:

http://www.dsource.org/projects/ddl/browser/trunk/enki/EnkiParser.d#L91

The above shows a different variation of a workaround: using "{}".  But the
problem still stands.  The code generator needs a way to provide a way to jump
to a known pass/fail point where it is known that there are no other
instructions that could generate side-effects.  Each "{}" closure also maps to a
particular production in the input grammar, and has its own variables for input
capture and rewinding the parse position - that's how I found #199 as well.

- EricAnderton at yahoo



More information about the Digitalmars-d-bugs mailing list