Hi,
I have internal error when I compile the unit (see source below):
~/proj/trunk/core/collection]$ fpc dlist.pas4
dlist.pas4(36,1) Fatal: Internal error 200301231
Fatal: Compilation aborted
Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
fpc version and system:
~/proj/trunk/core/collection]$ fpc -h | head -2
Free Pascal Compiler version 2.6.1 [2012/11/08] for i386 Copyright (c) 1993-2012 by Florian Klaempfl and others ~/proj/trunk/core/collection]$ uname -a
FreeBSD korica 8.3-RELEASE FreeBSD 8.3-RELEASE #0: Mon Apr 9 21:47:23 UTC 2012 i386
If I comment out all enumerator code it compiles success. How should I rewrite this code to make it works?
=============================
{$MODESWITCH RESULT}
unit dlist;
interface
type
generic TList<TValue> = object
public type
PNode = ^TNode;
TNode = record
Next: PNode;
Value: TValue;
end;
private type
TEnumerator = object
private
FNode: PNode;
function GetCurrent: TValue;
public
function MoveNext: Boolean;
property Current: TValue read GetCurrent;
end;
private
FFirst: TNode;
FLast: PNode;
public
constructor Init;
destructor Destroy;
procedure Insert(const Value: TValue);
function GetEnumerator: TEnumerator;
end;
implementation
function TList.TEnumerator.GetCurrent: TValue;
begin
Result := FNode^.Value;
end;
function TList.TEnumerator.MoveNext: Boolean;
begin
FNode := FNode^.Next;
Result := FNode nil;
end;
constructor TList.Init;
begin
FFirst.Next := nil;
FLast := @FFirst;
end;
destructor TList.Destroy;
begin
end;
procedure TList.Insert(const Value: TValue);
var
Node: PNode;
begin
New(Node);
Node^.Value := Value;
Node^.Next := nil;
FLast^.Next := Node;
FLast := Node;
end;
function TList.GetEnumerator: TEnumerator;
begin
Result.FNode := FFirst;
end;
end.
=============================