- fixed: The return prototyxpe may only be retrieved after the return state of the function has been checked. Also made this a real error message instead of an assert because it will inevitably result in a crash if the prototype cannot be generated, making diagnostics impossible.

This commit is contained in:
Christoph Oelckers 2016-11-05 21:02:26 +01:00
parent 0f9ebff3ee
commit b59f4e950f

View file

@ -715,13 +715,10 @@ 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);
@ -730,6 +727,13 @@ void FFunctionBuildList::Build()
item.Code = newcmpd->Resolve(ctx);
}
item.Proto = ctx.ReturnProto;
if (item.Proto == nullptr)
{
item.Code->ScriptPosition.Message(MSG_ERROR, "Function %s without prototype", item.PrintableName.GetChars());
continue;
}
// 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.