mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-24 01:16:04 +02:00
31 lines
505 B
ObjectPascal
31 lines
505 B
ObjectPascal
{ %FAIL }
|
|
|
|
program tanonfunc45;
|
|
|
|
{$mode objfpc}
|
|
{$modeswitch anonymousfunctions}
|
|
{$modeswitch functionreferences}
|
|
|
|
{ test that capturing open array arguments is rejected }
|
|
|
|
type
|
|
TIntFunc = reference to function: Integer;
|
|
|
|
function TestCaptureArray(A: array of Integer): TIntFunc;
|
|
begin
|
|
Result := function: Integer
|
|
var
|
|
I: Integer;
|
|
begin
|
|
Result := 0;
|
|
for I in A do
|
|
Inc(Result, I)
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
if TestCaptureArray([1, 2, 3, 4])() <> 10 then
|
|
Halt(1);
|
|
end.
|
|
|