ID:2750423
 
Resolved
Range cases in switch() didn't throw a compiler error when given non-constant or non-numeric values.
BYOND Version:514
Operating System:Windows 10 Home 64-bit
Web Browser:N/A
Applies to:Dream Maker
Status: Resolved (515.1600)

This issue has been resolved.
Descriptive Problem Summary: switch() range cases like `if(var_x to var_y)` aren't erroring when the var is not a constant expression, and it's causing incorrect behavior.

Numbered Steps to Reproduce Problem: Just see the code snippet below. Note that replacing `var/T` with `var/const/T` fixes it, but BYOND should already be throwing an "Expected a constant expression" error anyways. Currently there is no error.

Code Snippet (if applicable) to Reproduce Problem:
proc/test_code()
var/T = 5
switch(1)
if(T to 10e31)
world.log << "Yes"
else
world.log << "No"


Expected Results: "No"

Actual Results: "Yes"

Does the problem occur:
Every time? Or how often? Every time.
In other games? N/A
In other user accounts? N/A
On other computers? N/A

When does the problem NOT occur? When it's actually a constant expression.

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.) Didn't check.

Workarounds: Fix it to be a constant expression.

Bumping this because I saw it be a problem in production code yesterday.
Bump x 2
Lummox JR resolved issue with message:
Range cases in switch() didn't throw a compiler error when given non-constant or non-numeric values.