mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 22:47:59 +02:00

+ added tests The following rules for using these operator overloads as *implicit* overloads apply (Delphi compatible): - if a found assignment operator returns a default ShortString then that is used - if only one assignment operator to a String[x] is found then that is used - otherwise the assignment is not possible The explicit assignment checks for an exact match (and falls back for an implicit assignment). This is not entirely Delphi compatible as Delphi seems to favor the first found symbol in that case, but sometimes also not... :/ git-svn-id: trunk@47634 -
30 lines
394 B
ObjectPascal
30 lines
394 B
ObjectPascal
{ %FAIL }
|
|
|
|
program toperator95;
|
|
|
|
{$mode objfpc}
|
|
{$modeswitch advancedrecords}
|
|
|
|
type
|
|
TString80 = String[80];
|
|
TString90 = String[90];
|
|
|
|
TTest = record
|
|
class operator :=(const aArg: TTest): TString80;
|
|
end;
|
|
|
|
class operator TTest.:=(const aArg: TTest): TString80;
|
|
begin
|
|
end;
|
|
|
|
operator :=(const aArg: TTest): TString90;
|
|
begin
|
|
end;
|
|
|
|
var
|
|
t: TTest;
|
|
s80: TString80;
|
|
begin
|
|
s80 := t;
|
|
end.
|