diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index 2b0fd2bf3..a367b662e 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -721,10 +721,14 @@ namespace PascalABCCompiler.PCU { int pos = (int)bw.BaseStream.Position; members[dn] = pos; - name_pool[dn].offset = pos; - if (dn is common_namespace_function_node) - if ((dn as common_namespace_function_node).is_overload) - name_pool[dn].symbol_kind = symbol_kind.sk_overload_function; + if (name_pool.ContainsKey(dn)) + { + name_pool[dn].offset = pos; + if (dn is common_namespace_function_node) + if ((dn as common_namespace_function_node).is_overload) + name_pool[dn].symbol_kind = symbol_kind.sk_overload_function; + } + gl_members[dn] = pos; List pwl = null; //если какой-то модуль ждет смещения от этой сущности, сообщаем ему diff --git a/TestSuite/units/u_delegates5.pas b/TestSuite/units/u_delegates5.pas new file mode 100644 index 000000000..8eb5d567b --- /dev/null +++ b/TestSuite/units/u_delegates5.pas @@ -0,0 +1,18 @@ +unit u_delegates5; +interface + +implementation + +type + d = T->(); + +procedure Test; +begin + var i := 0; + var f: d := x -> begin i := x end; + f(2); + assert(i = 2); +end; +begin + Test; +end. \ No newline at end of file diff --git a/TestSuite/usesunits/use_delegates5.pas b/TestSuite/usesunits/use_delegates5.pas new file mode 100644 index 000000000..d4177bf81 --- /dev/null +++ b/TestSuite/usesunits/use_delegates5.pas @@ -0,0 +1 @@ +uses u_delegates5; begin end. \ No newline at end of file