[fpc-pascal] class operator enumerator
Ryan Joseph
ryan at thealchemistguild.com
Tue Apr 23 19:22:22 CEST 2019
Is "class operator enumerator” supposed to work or is this a bug that it compiles but doesn’t do anything? Seems like it should work.
===========================
{$mode objfpc}
{$modeswitch advancedrecords}
program test;
type
TArrayEnumerator = class
public type
TArrayValue = integer;
public
function GetCurrent: TArrayValue;
constructor Create(a: pointer);
property Current: TArrayValue read GetCurrent;
function MoveNext: Boolean;
end;
TRec = record
class operator enumerator(a: TRec): TArrayEnumerator;
end;
class operator TRec.Enumerator(a: TRec): TArrayEnumerator;
begin
result := TArrayEnumerator.Create(@a);
end;
function TArrayEnumerator.GetCurrent: TArrayValue;
begin
end;
constructor TArrayEnumerator.Create(a: pointer);
begin
end;
function TArrayEnumerator.MoveNext: Boolean;
begin
end;
var
arr: TRec;
value: integer;
begin
for value in arr do // <<<< ERROR: Cannot find an enumerator for the type "TRec"
begin
end;
end.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list