mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 21:49:32 +02:00
30 lines
442 B
ObjectPascal
30 lines
442 B
ObjectPascal
program tanonfunc66;
|
|
|
|
{$mode delphi}
|
|
{$modeswitch anonymousfunctions}
|
|
{$modeswitch functionreferences}
|
|
|
|
{ test generic local reference declaration
|
|
|
|
same as tanonfunc39 but mode delphi
|
|
}
|
|
|
|
procedure Foo;
|
|
type
|
|
TLocalFunc<T> = reference to function(arg: T): T;
|
|
var
|
|
F: TLocalFunc<longint>;
|
|
begin
|
|
F := function(arg: longint): longint
|
|
begin
|
|
Result := arg * arg;
|
|
end;
|
|
if F(5) <> 25 then
|
|
halt(1);
|
|
end;
|
|
|
|
begin
|
|
Foo;
|
|
end.
|
|
|