* ensure that all hidden parameter symbols are removed when adding an anonymous function to a capturer (they'll be added again later on)

This commit is contained in:
Sven/Sarah Barth 2022-12-30 22:48:44 +01:00
parent d7d65fe0d7
commit 430bcac389

View File

@ -1138,7 +1138,6 @@ implementation
invokename : tsymstr; invokename : tsymstr;
i : longint; i : longint;
outerself, outerself,
fpsym,
selfsym, selfsym,
sym : tsym; sym : tsym;
info : pcapturedsyminfo; info : pcapturedsyminfo;
@ -1147,6 +1146,7 @@ implementation
invokedef, invokedef,
parentdef, parentdef,
curpd : tprocdef; curpd : tprocdef;
syms : tfpobjectlist;
begin begin
capturer:=nil; capturer:=nil;
result:=funcref_intf_for_proc(pd,fileinfo_to_suffix(pd.fileinfo)); result:=funcref_intf_for_proc(pd,fileinfo_to_suffix(pd.fileinfo));
@ -1203,24 +1203,24 @@ implementation
pd.procsym.realname:=invokename; pd.procsym.realname:=invokename;
pd.parast.symtablelevel:=normal_function_level; pd.parast.symtablelevel:=normal_function_level;
pd.localst.symtablelevel:=normal_function_level; pd.localst.symtablelevel:=normal_function_level;
{ retrieve framepointer and self parameters if any } { collect all hidden parameters and especially the self parameter (if any) }
fpsym:=nil;
selfsym:=nil; selfsym:=nil;
syms:=tfpobjectlist.create(false);
for i:=0 to pd.parast.symlist.count-1 do for i:=0 to pd.parast.symlist.count-1 do
begin begin
sym:=tsym(pd.parast.symlist[i]); sym:=tsym(pd.parast.symlist[i]);
if sym.typ<>paravarsym then if sym.typ<>paravarsym then
continue; continue;
if vo_is_parentfp in tparavarsym(sym).varoptions then if vo_is_self in tparavarsym(sym).varoptions then
fpsym:=sym selfsym:=sym
else if vo_is_self in tparavarsym(sym).varoptions then else if vo_is_hidden_para in tparavarsym(sym).varoptions then
selfsym:=sym; syms.add(sym);
if assigned(fpsym) and assigned(selfsym) then
break;
end; end;
{ get rid of the framepointer parameter } { get rid of the hidden parameters; they will be added again during
if assigned(fpsym) then buildvmt of the capturer }
pd.parast.deletesym(fpsym); for i:=0 to syms.count-1 do
pd.parast.deletesym(tsym(syms[i]));
syms.free;
outerself:=nil; outerself:=nil;
{ complain about all symbols that can't be captured and add the symbols { complain about all symbols that can't be captured and add the symbols
to this procdefs capturedsyms if it isn't a top level function } to this procdefs capturedsyms if it isn't a top level function }