- 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,13 +715,6 @@ void FFunctionBuildList::Build()
FScriptPosition::StrictErrors = !item.FromDecorate;
item.Code = item.Code->Resolve(ctx);
if (!item.Code->CheckReturn())
{
auto newcmpd = new FxCompoundStatement(item.Code->ScriptPosition);
newcmpd->Add(item.Code);
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.
@ -729,6 +722,14 @@ void FFunctionBuildList::Build()
{
assert(item.Proto != nullptr);
if (!item.Code->CheckReturn())
{
auto newcmpd = new FxCompoundStatement(item.Code->ScriptPosition);
newcmpd->Add(item.Code);
newcmpd->Add(new FxReturnStatement(nullptr, item.Code->ScriptPosition));
item.Code = newcmpd->Resolve(ctx);
}
// Generate prototype for anonymous functions.
VMScriptFunction *sfunc = item.Function;
// create a new prototype from the now known return type and the argument list of the function's template prototype.