mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 15:28:08 +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 -
28 lines
373 B
ObjectPascal
28 lines
373 B
ObjectPascal
{ %NORUN }
|
|
|
|
program toperator93;
|
|
|
|
{$mode delphi}
|
|
|
|
type
|
|
TString80 = String[80];
|
|
TString90 = String[90];
|
|
TString40 = String[40];
|
|
TString100 = String[100];
|
|
|
|
TTest = record
|
|
class operator Implicit(const aArg: TTest): TString80;
|
|
end;
|
|
|
|
class operator TTest.Implicit(const aArg: TTest): TString80;
|
|
begin
|
|
|
|
end;
|
|
|
|
var
|
|
t: TTest;
|
|
s: TString80;
|
|
begin
|
|
s := t;
|
|
end.
|