ID:110074
 
Resolved
BYOND Version:479
Operating System:Windows 7 Home Basic
Web Browser:Chrome 10.0.648.114
Applies to:Dream Maker
Status: Resolved (481)

This issue has been resolved.
Descriptive Problem Summary:
Using break in a switch statement causes a compiler error. Dream Makers reference states 'The "break" instructor may be used to exit from a switch statement'
Example
mob
verb
Switch()
var/A="Test"
switch(A)
if("Test")
if(1==1)
break
world<<"Blah"
else
world<<"?"
world<<"Hi"

Expected Results:
Switches compiling with break statements.

Actual Results:
Compiler error: "break: not in a loop"

Workarounds:
Shoving the switch into a "do-while" that never loops, or labeling the switch and break.
Please include a code snippet.
Does the code I've added show a bug or a fault on my part?
It's fault on your part, I believe:
verb/test(i as num)
switch(i)
if(53)
break

is how it should be formatted (at least, in java)
Eh, that doesn't compile either.
It looks like it should be possible to add this, but there's a problem: Existing code may already be relying on the break statement to break out of an actual loop. I think the best fix here is just to change the reference.

I'll consult with Tom just in case though because it also seems like since the ref mentioned this, relying on the behavior contrary to what it said would be a bad thing.
Tom and I agree that because the C fall-through behavior isn't used here, supporting break in these kinds of switch() blocks isn't logical. The incorrect info in the reference entry has been changed.