Hi
Getting odd compiler error when building following tried with 4.5 and 4.6, same error
oh, and this is on current release and latest beta
namespace AsyncDeligateTest;
interface
uses
System.Linq,
System.Threading.Tasks;
type
Program = class
private
class method Caller(handler: Func<Integer,Func<Task>,Task>);
public
class method Main(args: array of String): Int32;
end;
implementation
class method Program.Main(args: array of String): Int32;
begin
Caller((i,t) -> begin
Console.WriteLine(i);
await t;
end);
end;
class method Program.Caller(handler: Func<Integer,Func<Task>,Task>);
begin
handler(10, -> await Task.Delay(1000));
end;
end.
This variant of above also gives an E0 Internal error: Object reference not set to an instance of an object
namespace AsyncDeligateTest;
interface
uses
System.Linq,
System.Threading.Tasks;
type
ITest = public interface
method WriteAsync(s: String): Task;
end;
Program = class
private
class method Caller(handler: Func<ITest,Func<Task>,Task>);
public
class method Main(args: array of String): Int32;
end;
implementation
class method Program.Main(args: array of String): Int32;
begin
Caller((ctx,next) -> begin
await ctx.WriteAsync('Testing');
await next;
end);
end;
class method Program.Caller(handler: Func<ITest,Func<Task>,Task>);
begin
handler(nil, -> await Task.Delay(1000));
end;
end.
So the error is completely wrong, but it fails because in await t “t” is a func (delegate). If you turn it into await t() it will work.I’m fixing the error message and the NRE now.