mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 02:09:12 +02:00
34 lines
467 B
ObjectPascal
34 lines
467 B
ObjectPascal
program tanonfunc30;
|
|
|
|
{$mode objfpc}
|
|
{$modeswitch anonymousfunctions}
|
|
{$modeswitch functionreferences}
|
|
|
|
{ test calling named function nested within an an anonymous method }
|
|
|
|
type
|
|
TIntFunc = reference to function: Integer;
|
|
|
|
function Foo: TIntFunc;
|
|
begin
|
|
Result := function: Integer
|
|
var x: Integer;
|
|
|
|
procedure bar;
|
|
begin
|
|
Inc(x, 2);
|
|
end;
|
|
|
|
begin
|
|
x := 1;
|
|
bar;
|
|
Result := x;
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
if foo()() <> 3 then
|
|
halt(1);
|
|
end.
|
|
|