- made 'return void' case a compilation error

This commit is contained in:
alexey.lysiuk 2018-11-01 11:57:09 +02:00 committed by Christoph Oelckers
parent b79622bcba
commit d3461be40c
1 changed files with 9 additions and 8 deletions

View File

@ -10629,7 +10629,14 @@ FxExpression *FxReturnStatement::Resolve(FCompileContext &ctx)
}
PPrototype *retproto;
if (Args.Size() == 0)
if (ctx.ReturnProto != nullptr && ctx.ReturnProto->ReturnTypes.Size() != Args.Size())
{
ScriptPosition.Message(MSG_ERROR, "Incorrect number of return values. Got %u, but expected %u", Args.Size(), ctx.ReturnProto->ReturnTypes.Size());
delete this;
return nullptr;
}
else if (Args.Size() == 0)
{
TArray<PType *> none(0);
retproto = NewPrototype(none, none);
@ -10645,7 +10652,7 @@ FxExpression *FxReturnStatement::Resolve(FCompileContext &ctx)
}
retproto = Args[0]->ReturnProto();
}
else if (ctx.ReturnProto != nullptr && ctx.ReturnProto->ReturnTypes.Size() == Args.Size())
else
{
for (unsigned i = 0; i < Args.Size(); i++)
{
@ -10660,12 +10667,6 @@ FxExpression *FxReturnStatement::Resolve(FCompileContext &ctx)
}
return this; // no point calling CheckReturn here.
}
else
{
ScriptPosition.Message(MSG_ERROR, "Incorrect number of return values. Got %u, but expected %u", Args.Size(), ctx.ReturnProto->ReturnTypes.Size());
delete this;
return nullptr;
}
ctx.CheckReturn(retproto, ScriptPosition);