Fixed crash on functions with missing return values

This commit is contained in:
Boondorl 2024-11-04 23:54:31 -05:00 committed by Rachael Alexanderson
parent 3d4dccd650
commit d85d04f421

View file

@ -878,12 +878,20 @@ void FFunctionBuildList::Build()
if (item.Code != nullptr)
{
if (!item.Code->CheckReturn())
{
if (ctx.ReturnProto == nullptr || !ctx.ReturnProto->ReturnTypes.Size())
{
auto newcmpd = new FxCompoundStatement(item.Code->ScriptPosition);
newcmpd->Add(item.Code);
newcmpd->Add(new FxReturnStatement(nullptr, item.Code->ScriptPosition));
item.Code = newcmpd->Resolve(ctx);
}
else
{
item.Code->ScriptPosition.Message(MSG_ERROR, "Missing return statement in %s", item.PrintableName.GetChars());
continue;
}
}
item.Proto = ctx.ReturnProto;
if (item.Proto == nullptr)