ID:2552595
 
BYOND Version:513
Operating System:Windows 10 Pro 64-bit
Web Browser:Firefox 74.0
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary:

The switch proc prioritizes ranges over single values, against what most coders would expect. I'll give code examples.

Code Snippet (if applicable) to Reproduce Problem:
switch(5)
if(4 to 6)
world.log << "Range is prioritized"
if(5)
world.log << "Single value is prioritized"


Unaffected by order, result is the same:
switch(5)
if(5)
world.log << "Single value is prioritized"
if(4 to 6)
world.log << "Range is prioritized"


Expected Results:
An output of "Single value is prioritized"

Actual Results:
An output of "Range is prioritized"

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
I have not tested beyond 512 and 513, in both of which it behaves in this way, and am not aware if it ever worked differently.
I'm kind of tempted to throw this in the "Not a bug" pile. There's really no reason you should be doing this, and if anything the compiler should spit out an error for it.
How about this kind of code:
switch(5)
if(5)
a()
if(5 to 6)
b()
if(6)
c()


The result is the same as before, range is prioritized.
Why is this not valid syntax? What part of it should spit out an error - what kind of error?
The fact that you're reusing a value in two different places would spit out an error in any C compiler.