ID:2336571
 
BYOND Version:511
Operating System:Windows 10 Enterprise 64-bit
Web Browser:Firefox 57.0
Applies to:Dream Maker
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary:
Switch statements using if(A to B) with non-constant A or B compile (they shouldn't), resulting in broken bytecode.

The bug is ANCIENT, possibly just as old as 0x7A opcode and "if(A to B)" syntax, since some of SS13 codebases use this syntax for a long long time.


Numbered Steps to Reproduce Problem:
1. Copy/paste the snippet.
2. Compile it (no error).
3. Run it to confirm it doesn't work.
4. Open the bytecode with whatever internal tool you are using to confirm that it couldn't possibly work.

Code Snippet (if applicable) to Reproduce Problem:
/mob/verb/lol(meme as num)
var/a = 12
switch(meme)
if(6 to a)
usr << "6 to 12"
if(a+1 to 24)
usr << "13 to 24"


Expected Results:
I expect compiler to throw an "expected a constant expression" error.


Actual Results:
Compiler doesn't print any errors and generates broken bytecode instead. Said bytecode also doesn't print a single error when executed, resulting in bugs that are hard to catch. Generated switch opcode example:
0x7a,

0x2,
0x4bdc, 0xfb4c, 0x960d, 0xddf8, 0x15,
0x4bdc, 0xfb4c, 0x960d, 0xddf8, 0x1c,

0x0,

0x23


Does the problem occur:
Every time? Or how often?
Every time.
In other user accounts?
On other computers?
Not tested, should also occur.