ID:2876217
 
Resolved
In a switch() block, a single-line statement after an else (on the same level of indentation as the else) could compile incorrectly without producing any compiler error.
BYOND Version:515.1602
Operating System:Windows 10 Pro 64-bit
Web Browser:Chrome 114.0.0.0
Applies to:Dream Maker
Status: Resolved (515.1609)

This issue has been resolved.
Descriptive Problem Summary:

switch() allows certain invalid syntax to compile, but not run correctly.

Code Snippet (if applicable) to Reproduce Problem:
proc
popid2num(str)
var/digits = length(str), pos = 1, id
. = 0
for(var/n in digits to 1 step -1)
switch((id = text2ascii(str,pos++)))
if(97)
continue
if(65 to 90)
id = 26 + id-65
if(98 to 122)
id = id - 97
else
throw EXCEPTION("Invalid pop id: [str]")

. += id * 52 ** (n - 1)


Expected Results:

I'd very much expect this to throw a compiler error

Actual Results:

It compiles. I'm not at all sure to what, but it's not right.
If the . += line is present, the exception line seems to jump back up to the top of the for loop. lol

https://file.house/Z-TZ.png
Lummox JR resolved issue with message:
In a switch() block, a single-line statement after an else (on the same level of indentation as the else) could compile incorrectly without producing any compiler error.