- fixed: The return checking code must be inside the nullptr check for item.code.

This commit is contained in:
Christoph Oelckers 2016-11-05 18:56:04 +01:00
parent 0851d698de
commit 0f9ebff3ee

View file

@ -715,6 +715,13 @@ void FFunctionBuildList::Build()
FScriptPosition::StrictErrors = !item.FromDecorate;
item.Code = item.Code->Resolve(ctx);
item.Proto = ctx.ReturnProto;
// Make sure resolving it didn't obliterate it.
if (item.Code != nullptr)
{
assert(item.Proto != nullptr);
if (!item.Code->CheckReturn())
{
auto newcmpd = new FxCompoundStatement(item.Code->ScriptPosition);
@ -722,12 +729,6 @@ void FFunctionBuildList::Build()
newcmpd->Add(new FxReturnStatement(nullptr, item.Code->ScriptPosition));
item.Code = newcmpd->Resolve(ctx);
}
item.Proto = ctx.ReturnProto;
// Make sure resolving it didn't obliterate it.
if (item.Code != nullptr)
{
assert(item.Proto != nullptr);
// Generate prototype for anonymous functions.
VMScriptFunction *sfunc = item.Function;