- 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.
This commit is contained in:
Christoph Oelckers 2021-08-10 19:03:40 +02:00
parent 55520ed7d0
commit 03b7324f71

View file

@ -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);