Fix wrong function index on some recursive calls

- problem: function index for recursive calls does not get updated in
  cases when the definition of the function comes before its use
- solution: treat the function as predefined until we process the whole
  of its body so that a ref gets added if a recusive call is encountered
This commit is contained in:
rhinoduck 2015-10-10 17:16:32 +02:00
parent ae5f03691a
commit ae6b71612e

14
parse.c
View file

@ -825,8 +825,18 @@ static void OuterFunction(void)
else
{
sym = SY_InsertGlobal(tk_String, SY_SCRIPTFUNC);
sym->info.scriptFunc.address = (importing == IMPORT_Importing ? 0 : pc_Address);
sym->info.scriptFunc.predefined = NO;
if (importing == IMPORT_Importing)
{
sym->info.scriptFunc.address = 0;
sym->info.scriptFunc.predefined = NO;
}
else
{
sym->info.scriptFunc.address = pc_Address;
sym->info.scriptFunc.predefined = YES;
// only for consistency with other speculated functions and pretty logs
sym->info.scriptFunc.funcNumber = 0;
}
}
defLine = tk_Line;