I'll try to answer your question, but first...
DO NOT USE Goto.
I don't know why they added Goto to the language, but you don't need it and it has just led to this specific problem coming up repeatedly.
So, before I answer your question, let me remind you...
DO NOT USE Goto EVER, EVEN AFTER I EXPLAIN HOW TO FIX THIS
I can't even really specify exactly the sequence of events that leads to this, but it has something to do with how the front end parses an expression and then whether it thinks the expression containing the Goto and Label are in the same CompoundExpression (or some containing CompoundExpression higher up the syntax tree). In your case, there's no question that they really are in the same CompoundExpression, but somewhere along the line between front-end parsing and back end evaluation, it got confused and can't determine that the Goto and Label are in the same CompoundExpression.
Here's how you can fix it, but first let me remind you...
IF YOU THINK YOU NEED TO USE Goto IN YOUR CODE, YOU ARE WRONG--YOU DO NOT EVER EVER EVER NEED TO USE Goto
Okay, you need to help the front end (or back end, wherever the confusion comes from) not get confused. You can do this by:
- Delete all newlines. This way the
CompoundExpression will be on one line. Now, the front end actually tries to displays long expressions nicely, so you will see some wraparound, and it may end up looking exactly the same as what you started with. But anyway, newlines cause trouble here.
Okay, now we're getting really crazy. Wrap your whole expression in ReleaseHold[Hold[...]]:
ReleaseHold[Hold[
i = 0;
Label[start];
i++;
If[i == 20, Goto[end], Goto[start]];
Label[end]; Print[i]]]
I honestly don't know if that's guaranteed to always work, but it does work for your code. Somehow this interrupts execution in a way that allows the parsing to work correctly. Or something. Shrug.
You can also try just wrapping your expression in parentheses. This is another syntax/structure hint to the parser, and it did work on your code, but again, I'm reallly not sure if this is a guaranteed fix.
Now, please forget everything I told you and forget that Goto exists.