[Lazarus] Lazarus trunc does not compile with fpc 2.6.4 Win32
Ondrej Pokorny
lazarus at kluug.net
Mon Jan 11 17:42:23 CET 2016
On 11.01.2016 16:32, Mattias Gaertner wrote:
> On Mon, 11 Jan 2016 16:13:49 +0100
> Ondrej Pokorny<lazarus at kluug.net> wrote:
>
>> I think it fails to find exact overloads.
> There is no overload. There is only one definition:
>
> {$define PathStr:=RawByteString}
>
> function ChangeFileExt(const FileName, Extension: PathStr): PathStr;
finah.inc is loaded twice with different PathStr macro so there are
effectively 2 overloaded ChangeFileExt.
The issue can be easily reproduced (try to complete X):
function StrFunc(Str: string): string;
begin
Result := Str;
end;
function StrFunc(Str: RawByteString): RawByteString;
begin
Result := Str;
end;
procedure Test;
var
R: RawByteString;
S: string;
begin
X := StrFunc(S);
end;
This is because both string and RawByteString have the same default type
(AnsiString) in CodeTools.
The same is for numbers (and any other type defined with "child = type
parent"):
type
PtrInt = type Longint;
function NumFunc(Num: PtrInt): PtrInt;
begin
Result := Num;
end;
function NumFunc(Num: Integer): Integer;
begin
Result := Num;
end;
procedure Test;
var
I: Integer;
P: PtrInt;
begin
X := NumFunc(P);
end;
=> CodeTools fail to find the exact matching overload if there is
another less good (but still acceptable) overload. CodeTools are fine
when they found one compatible overload, not the best that is actually
picked up by the compiler.
Are you aware of this bug (or are you aware of an issue report in mantis)?
Ondrej
More information about the Lazarus
mailing list