* consider Self parameters of nested functions as captured as well

This commit is contained in:
Sven/Sarah Barth 2021-07-22 17:19:50 +02:00
parent d56a90e5ed
commit 5129c2cb9a

View File

@ -390,7 +390,13 @@ implementation
{ reference in nested procedures, variable needs to be in memory }
{ and behaves as if its address escapes its parent block }
make_not_regable(self,[ra_different_scope]);
end;
end
{ if this is a nested function and it uses the Self parameter then
consider this as captured as well (needed for anonymous functions) }
else if assigned(current_procinfo) and
(vo_is_self in tabstractvarsym(symtableentry).varoptions) and
(symtable.symtablelevel>normal_function_level) then
current_procinfo.add_captured_sym(symtableentry,fileinfo);
resultdef:=tabstractvarsym(symtableentry).vardef;
{ e.g. self for objects is passed as var-parameter on the caller