From 90447ae2e18b342960ac1e5ec6238b9d07a1c8f8 Mon Sep 17 00:00:00 2001 From: ike709 Date: Thu, 17 Sep 2026 21:09:47 -0500 Subject: [PATCH 1/2] Fix mis-parsing `else:` in `switch()` statements --- .../DMProject/Tests/Statements/Switch/else_colon.dm | 10 ++++++++++ DMCompiler/Compiler/DM/DMParser.cs | 1 + 2 files changed, 11 insertions(+) create mode 100644 Content.Tests/DMProject/Tests/Statements/Switch/else_colon.dm diff --git a/Content.Tests/DMProject/Tests/Statements/Switch/else_colon.dm b/Content.Tests/DMProject/Tests/Statements/Switch/else_colon.dm new file mode 100644 index 0000000000..aa821136f9 --- /dev/null +++ b/Content.Tests/DMProject/Tests/Statements/Switch/else_colon.dm @@ -0,0 +1,10 @@ +// RETURN TRUE + +/proc/RunTest() + var/foo = 5 + switch(foo) + if(2) + return FALSE + else: + return TRUE + return FALSE diff --git a/DMCompiler/Compiler/DM/DMParser.cs b/DMCompiler/Compiler/DM/DMParser.cs index 13b6841524..f68974a543 100644 --- a/DMCompiler/Compiler/DM/DMParser.cs +++ b/DMCompiler/Compiler/DM/DMParser.cs @@ -1547,6 +1547,7 @@ private DMASTProcStatementSwitch.SwitchCase[] SwitchInner() { return new DMASTProcStatementSwitch.SwitchCaseValues(expressions.ToArray(), body); } else if (Check(TokenType.DM_Else)) { + Check(TokenType.DM_Colon); // Someone wrote "else:" instead of "else" Whitespace(); var loc = Current().Location; if (Current().Type == TokenType.DM_If) { From 06b42d2c85a97538b1e742de5736ee1481c30db5 Mon Sep 17 00:00:00 2001 From: wixoa Date: Fri, 18 Sep 2026 04:15:05 -0400 Subject: [PATCH 2/2] Update DMCompiler/Compiler/DM/DMParser.cs --- DMCompiler/Compiler/DM/DMParser.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DMCompiler/Compiler/DM/DMParser.cs b/DMCompiler/Compiler/DM/DMParser.cs index f68974a543..c8b41019c2 100644 --- a/DMCompiler/Compiler/DM/DMParser.cs +++ b/DMCompiler/Compiler/DM/DMParser.cs @@ -1547,6 +1547,7 @@ private DMASTProcStatementSwitch.SwitchCase[] SwitchInner() { return new DMASTProcStatementSwitch.SwitchCaseValues(expressions.ToArray(), body); } else if (Check(TokenType.DM_Else)) { + Whitespace(); Check(TokenType.DM_Colon); // Someone wrote "else:" instead of "else" Whitespace(); var loc = Current().Location;