diff --git a/TestSuite/lambdas_closures_12.pas b/TestSuite/lambdas_closures_12.pas new file mode 100644 index 000000000..654d0caed --- /dev/null +++ b/TestSuite/lambdas_closures_12.pas @@ -0,0 +1,24 @@ +var i: integer; +type + t2 = class + procedure Redraw; + begin + i := 1; + end; + + constructor(Redraw: boolean); + begin + var p:procedure := ()-> + begin + if Redraw then + self.Redraw; + end; + p; + end; + + end; + +begin +new t2(true); +assert(i = 1); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/compilation_context.cs b/TreeConverter/TreeConversion/compilation_context.cs index 8f492a17e..bb7c7798d 100644 --- a/TreeConverter/TreeConversion/compilation_context.cs +++ b/TreeConverter/TreeConversion/compilation_context.cs @@ -2130,7 +2130,16 @@ namespace PascalABCCompiler.TreeConverter SymbolInfoList si = curscope.Find(name, curscope); - + SymbolInfoList si2 = null; + if (si != null && si.First().scope is SymbolTable.ClassScope && curscope.TopScope is SymbolTable.BlockScope && curscope.TopScope.TopScope is SymbolTable.ClassMethodScope && curscope.TopScope.TopScope.TopScope is SymbolTable.BlockScope) + { + si2 = curscope.TopScope.TopScope.TopScope.Find(name, curscope.TopScope.TopScope.TopScope); + if (si2 != null && si2.First().scope is SymbolTable.ClassMethodScope) + { + si = si2; + } + } + if (si == null && _compiled_tn != null && curscope.TopScope != null) { SymbolTable.Scope tmp = curscope.TopScope;