From 3eb1d2bd85653571390ea407992a49333543d6c3 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Sun, 22 Sep 2024 17:42:09 +0200 Subject: [PATCH] #3197 --- TestSuite/lambdas26.pas | 9 +++++++++ .../TreeConversion/convertion_data_and_alghoritms.cs | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 TestSuite/lambdas26.pas 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)