From b59f4e950f83602b4058fe3bfde546b1c7da164e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Nov 2016 21:02:26 +0100 Subject: [PATCH] - 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. --- src/scripting/vm/vmbuilder.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/scripting/vm/vmbuilder.cpp b/src/scripting/vm/vmbuilder.cpp index aa6188f90..f8ca44ba6 100644 --- a/src/scripting/vm/vmbuilder.cpp +++ b/src/scripting/vm/vmbuilder.cpp @@ -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.