diff --git a/TestSuite/lambdas26.pas b/TestSuite/lambdas26.pas new file mode 100644 index 000000000..42991a871 --- /dev/null +++ b/TestSuite/lambdas26.pas @@ -0,0 +1,9 @@ +begin + var p := (p0: procedure)-> + begin + p0(); + end; + var i := 0; + p(()->begin Inc(i) end); + assert(i = 1); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 21eb03f53..4ff5d9398 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -655,7 +655,12 @@ namespace PascalABCCompiler.TreeConverter //TODO: А если наследование? possible_type_convertions pct = type_table.get_convertions(en.type,to); - + if (pct.first == null && pct.second == null && en.type is delegated_methods && to.IsDelegate) + { + pct = type_table.get_convertions(to, en.type); + if (pct.first != null) + return en; + } if (pct.second!=null) { if (pct.second.to == null && en is typed_expression && !to.IsDelegate)