diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 77ac9498c..1f2b038f1 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -5058,6 +5058,13 @@ FxExpression *FxNew::Resolve(FCompileContext &ctx) if (val->isConstant()) { auto cls = static_cast(static_cast(val)->GetValue().GetPointer()); + if ((cls->ObjectFlags & OF_Abstract) && cls != ctx.Class) + { + ScriptPosition.Message(MSG_ERROR, "Cannot instantiate abstract class %s outside of that class", cls->TypeName.GetChars()); + delete this; + return nullptr; + } + ValueType = NewPointer(cls); }