Don't crash on functions declared inside other functions

Declaring a local variable inside any function works the same way as
declaring it in top-level scope, which gets a bit weird if done inside a
function inside a constant proplist, but is at least consistent.

Thanks to Flinti for reporting this.
qteditor
Günther Brammer 2016-05-25 01:02:05 +02:00
parent a71ca69f1d
commit 57a35bf01b
1 changed files with 2 additions and 0 deletions

View File

@ -2175,6 +2175,7 @@ C4Value C4AulParse::Parse_ConstExpression(C4PropListStatic * parent, C4String *
throw C4AulParseError(this, "global functions must be declared with 'global func'");
if (!Name)
throw C4AulParseError(this, "functions must have a name");
C4AulScriptFunc * prev_Fn = Fn;
if (Type == PREPARSER)
{
Fn = new C4AulScriptFunc(parent, pOrgScript, Name ? Name->GetCStr() : NULL, SPos);
@ -2192,6 +2193,7 @@ C4Value C4AulParse::Parse_ConstExpression(C4PropListStatic * parent, C4String *
Store_Const(parent, Name, r);
Shift();
Parse_FuncBody();
Fn = prev_Fn;
}
else
{