ID:2658185
 
Resolved
BYOND Version:513
Operating System:Linux
Web Browser:Chrome 88.0.4324.182
Applies to:DM Language
Status: Resolved

This issue has been resolved.
Descriptive Problem Summary:
Bounded switch statement cases are selected from first, even over individual value cases irrespective of order, as stated in the reference material.


Numbered Steps to Reproduce Problem:
1: Create a switch statement
2: Add an exact equals case, [if(1)]
2: add a bounded case that encompasses that match. [if(1 to 50)]
3: Regardless of order of cases, the bounded case will take precidence.


Code Snippet (if applicable) to Reproduce Problem:
/proc/main()
var/testval = 1
switch(testval) //var/Bounded (Workaround applied.)
if(1 to 1)
world.log << "FIRST VALID MATCH-SWITCH1"
if(1 to 5)
world.log << "SECOND VALID MATCH-SWITCH1"
if(5 to 10)
world.log << "SHOULD NOT TRIGGER"
switch(testval) //var/Simple Immediate
if(1)
world.log << "FIRST VALID MATCH-SWITCH2"
if(1 to 5)
world.log << "SECOND VALID MATCH-SWITCH2"
if(5 to 10)
world.log << "SHOULD NOT TRIGGER"
switch(testval) //var/Simple Immediate Mid-range
if(1)
world.log << "FIRST VALID MATCH-SWITCH3"
if(0 to 5)
world.log << "SECOND VALID MATCH-SWITCH3"
if(5 to 10)
world.log << "SHOULD NOT TRIGGER"
switch(1) //Immediate/Immediate Mid-range
if(1)
world.log << "FIRST VALID MATCH-SWITCH4"
if(0 to 5)
world.log << "SECOND VALID MATCH-SWITCH4"
if(5 to 10)
world.log << "SHOULD NOT TRIGGER"
switch(2) //Immediate/Immediate Mid-range
if(2)
world.log << "FIRST VALID MATCH-SWITCH5"
if(0 to 5)
world.log << "SECOND VALID MATCH-SWITCH5"
if(5 to 10)
world.log << "SHOULD NOT TRIGGER"


Expected Results:
FIRST VALID MATCH-SWITCH1
FIRST VALID MATCH-SWITCH2
FIRST VALID MATCH-SWITCH3
FIRST VALID MATCH-SWITCH4
FIRST VALID MATCH-SWITCH5
Actual Results:
FIRST VALID MATCH-SWITCH1
SECOND VALID MATCH-SWITCH2
SECOND VALID MATCH-SWITCH3
SECOND VALID MATCH-SWITCH4
SECOND VALID MATCH-SWITCH5
Does the problem occur:
Every time? Or how often? Always.
In other games? Language flaw.
In other user accounts? Yes
On other computers? Yes.

When does the problem NOT occur?
It should occur reliably.

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.)
Problem occurs under 513.1542-514.1546 at the least under linux.
Problem verified under 471.1076 for posterity.

Workarounds:
Bound the specific variable to itself, such as in switch statement 1:
if(1 to 1)

Lummox JR resolved issue
I've added clarification in the reference that because overlapping ranges will not generate an error or warning, the resulting behavior is undefined.