This commit is contained in:
Ivan Bondarev 2024-09-22 17:42:09 +02:00
parent 20edd487e3
commit 3eb1d2bd85
2 changed files with 15 additions and 1 deletions

9
TestSuite/lambdas26.pas Normal file
View file

@ -0,0 +1,9 @@
begin
var p := (p0: procedure)->
begin
p0();
end;
var i := 0;
p(()->begin Inc(i) end);
assert(i = 1);
end.

View file

@ -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)