Hi everyone, great work! You’re all awesome!
I was testing Lazarus RC2 (
https://forum.lazarus.freepascal.org/index.php/topic,69820.60.html) and encountered an issue with a project that compiles without problems in the trunk but fails to compile in RC2 due to differences between FPC trunk and FPC 3.2.2. Would you recommend addressing these issues for FPC 3.2.4?
1) In Generics.Default, FPC trunk uses const (instead of constref) in TComparer.Compare:
TComparer<T> = class(TInterfacedObject, IComparer<T>)
public
class function Default: IComparer<T>; static;
function Compare(constref ALeft, ARight: T): Integer; virtual; abstract; overload;
class function Construct(const AComparison: TOnComparison<T>): IComparer<T>; overload;
class function Construct(const AComparison: TComparisonFunc<T>): IComparer<T>; overload;
end;
2) FPC 3.2.2 do not propagate String helpers for ShortString's. Hence:
// one may change this
TObject.ClassName.Replace('T', '');
// to this
String(TObject.ClassName).Replace('T', '');
3) I am getting an internal error 200510032, and also "Undefined symbol: .Lj2139" when trying to use .ToInteger helper with a specialized TDictionary:
program rc2test;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes,
SysUtils,
Generics.Collections;
procedure DoIt;
type
TMyDictionary = specialize TDictionary<string, string>;
var
MyDictionary : TMyDictionary;
begin
MyDictionary := TMyDictionary.Create;
try
MyDictionary.Add('Key', '1');
WriteLn(MyDictionary['Key'].ToInteger);
finally
MyDictionary.Free;
end;
end;
begin
DoIt;
ReadLn;
end.
I managed to compile it doing some refactoring:
var
s1 : string;
begin
s1 := MyDictionary['Numeric'];
WriteLn(s1.ToInteger);
end;
4) TEvent.Create, from syncobjs unit is not overloaded in FPC 3.2.2, so one must create it explicitly. FPC 3.3.1 will call "BasicEventCreate(nil, True,False,'')" when using the overloaded constructor.