diff --git a/DMCompiler/Compiler/DM/DMParser.cs b/DMCompiler/Compiler/DM/DMParser.cs index d9c2554a89..a163037474 100644 --- a/DMCompiler/Compiler/DM/DMParser.cs +++ b/DMCompiler/Compiler/DM/DMParser.cs @@ -1065,7 +1065,12 @@ private DMASTProcStatementSet[] ProcSetEnd(bool allowMultiple) { Consume(TokenType.DM_LeftParenthesis, "Expected '('"); BracketWhitespace(); DMASTExpression? condition = Expression(); - if (condition == null) Error("Expected a condition"); + if (condition == null) { + Error("Expected a condition"); + } + if (condition is DMASTAssign) { + DMCompiler.Emit(WarningCode.AssignmentInConditional, condition.Location, "Assignment in conditional"); + } BracketWhitespace(); ConsumeRightParenthesis(); Whitespace(); diff --git a/DMCompiler/DMStandard/DefaultPragmaConfig.dm b/DMCompiler/DMStandard/DefaultPragmaConfig.dm index e256ae41a6..5b97c1dbbe 100644 --- a/DMCompiler/DMStandard/DefaultPragmaConfig.dm +++ b/DMCompiler/DMStandard/DefaultPragmaConfig.dm @@ -33,4 +33,4 @@ #pragma EmptyBlock notice #pragma EmptyProc disabled // NOTE: If you enable this in OD's default pragma config file, it will emit for OD's DMStandard. Put it in your codebase's pragma config file. #pragma UnsafeClientAccess disabled // NOTE: Only checks for unsafe accesses like "client.foobar" and doesn't consider if the client was already null-checked earlier in the proc - +#pragma AssignmentInConditional warning diff --git a/OpenDreamShared/Compiler/CompilerError.cs b/OpenDreamShared/Compiler/CompilerError.cs index 10b15cb7c9..d5f9e299d3 100644 --- a/OpenDreamShared/Compiler/CompilerError.cs +++ b/OpenDreamShared/Compiler/CompilerError.cs @@ -59,6 +59,7 @@ public enum WarningCode { EmptyProc = 3101, UnsafeClientAccess = 3200, SuspiciousSwitchCase = 3201, // "else if" cases are actually valid DM, they just spontaneously end the switch context and begin an if-else ladder within the else case of the switch + AssignmentInConditional = 3202, // 4000 - 4999 are reserved for runtime configuration. (TODO: Runtime doesn't know about configs yet!) }