This commit is contained in:
Ivan Bondarev 2022-07-03 12:19:20 +02:00
parent 1680232dcb
commit 539a689732
3 changed files with 19 additions and 2 deletions

17
TestSuite/delegates19.pas Normal file
View file

@ -0,0 +1,17 @@
var i: integer;
procedure p1;
begin
end;
procedure p2;
begin
end;
procedure p3(p: procedure);
begin
i := 1;
end;
begin
p3(true?p1:p2);
assert(i = 1);
end.

View file

@ -668,7 +668,7 @@ namespace PascalABCCompiler.TreeConverter
if (pct.first==null)
{
if (to is delegated_methods && (to as delegated_methods).empty_param_method != null)
if (to is delegated_methods && (to as delegated_methods).empty_param_method != null && (to as delegated_methods).empty_param_method.ret_type != null)
{
return convert_type(en, (to as delegated_methods).empty_param_method.ret_type, loc);
}

View file

@ -18618,7 +18618,7 @@ namespace PascalABCCompiler.TreeConverter
{
delegated_methods del_left = left.type as delegated_methods;
delegated_methods del_right = right.type as delegated_methods;
if (del_left != null && del_right != null && del_left.empty_param_method == null && del_right.empty_param_method == null)
if (del_left != null && del_right != null && (del_left.empty_param_method == null && del_right.empty_param_method == null || del_left.empty_param_method.ret_type == null && del_right.empty_param_method.ret_type == null))
{
base_function_call bfc = del_left.proper_methods[0];
common_type_node del =