diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 626dcde242..f45bea5e34 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -1847,8 +1847,8 @@ FxExpression *FxUnaryNotBoolean::Resolve(FCompileContext& ctx) ExpEmit FxUnaryNotBoolean::Emit(VMFunctionBuilder *build) { - assert(Operand->ValueType == ValueType); - assert(ValueType == TypeBool); + assert(Operand->ValueType == TypeBool); + assert(ValueType == TypeBool || IsInteger()); // this may have been changed by an int cast. ExpEmit from = Operand->Emit(build); assert(!from.Konst); // boolean not is the same as XOR-ing the lowest bit @@ -8069,11 +8069,10 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) { if (!cls->IsDescendantOf(desttype)) { - ScriptPosition.Message(MSG_ERROR, "class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); - delete this; - return nullptr; + ScriptPosition.Message(MSG_OPTERROR, "class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); + cls = nullptr; } - ScriptPosition.Message(MSG_DEBUGLOG, "resolving '%s' as class name", clsname.GetChars()); + else ScriptPosition.Message(MSG_DEBUGLOG, "resolving '%s' as class name", clsname.GetChars()); } } FxExpression *x = new FxConstant(cls, to, ScriptPosition); diff --git a/src/scripting/decorate/thingdef_exp.cpp b/src/scripting/decorate/thingdef_exp.cpp index 229c8f1f48..2d69be3405 100644 --- a/src/scripting/decorate/thingdef_exp.cpp +++ b/src/scripting/decorate/thingdef_exp.cpp @@ -477,9 +477,12 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls) exp = new FxRuntimeStateIndex(ParseExpressionM(sc, cls)); } // The parsed expression is of type 'statelabel', but we want a real state here so we must convert it. - FArgumentList args; - args.Push(exp); - exp = new FxFunctionCall(NAME_ResolveState, NAME_None, args, sc); + if (!exp->isConstant()) + { + FArgumentList args; + args.Push(exp); + exp = new FxFunctionCall(NAME_ResolveState, NAME_None, args, sc); + } sc.MustGetToken(')'); return exp; }