Emit a message when trying to use something non-integral as a boolean

- It's not exactly optimal, since it silently removes the offending
  expression, but it's better than crashing.
This commit is contained in:
Randy Heit 2016-02-05 22:16:56 -06:00
parent 09a17c2198
commit 48dcbabd60

View file

@ -143,11 +143,13 @@ FxExpression *FxExpression::Resolve(FCompileContext &ctx)
FxExpression *FxExpression::ResolveAsBoolean(FCompileContext &ctx) FxExpression *FxExpression::ResolveAsBoolean(FCompileContext &ctx)
{ {
///FIXME: Use an actual boolean type
FxExpression *x = Resolve(ctx); FxExpression *x = Resolve(ctx);
if (x != NULL) if (x != NULL)
{ {
switch (x->ValueType.Type) switch (x->ValueType.Type)
{ {
case VAL_Int:
case VAL_Sound: case VAL_Sound:
case VAL_Color: case VAL_Color:
case VAL_Name: case VAL_Name:
@ -155,6 +157,9 @@ FxExpression *FxExpression::ResolveAsBoolean(FCompileContext &ctx)
break; break;
default: default:
ScriptPosition.Message(MSG_ERROR, "Not an integral type");
delete this;
return NULL;
break; break;
} }
} }