From 03b7324f717b7242f7c9489d3ff1d4dda238792e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 19:03:40 +0200 Subject: [PATCH] - reorder evaluation for 'if' statements to handle the condition first. Otherwise this won't emit errors if a bad condition is used with an empty conditional part. --- src/common/scripting/backend/codegen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 6a551f1c6..17e148335 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -9823,6 +9823,8 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx) { CHECKRESOLVED(); + SAFE_RESOLVE(Condition, ctx); + if (WhenTrue == nullptr && WhenFalse == nullptr) { // We don't do anything either way, so disappear delete this; @@ -9830,8 +9832,6 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx) return new FxNop(ScriptPosition); } - SAFE_RESOLVE(Condition, ctx); - if (Condition->ValueType != TypeBool) { Condition = new FxBoolCast(Condition, false);