summaryrefslogtreecommitdiff
path: root/tests/test/toperator93.pp
diff options
context:
space:
mode:
authorsvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-26 06:18:40 +0000
committersvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-26 06:18:40 +0000
commit6432b512726f0b3167ec916c5cf67cf3dfbd922a (patch)
tree130f8f282e13e90d78116c5bf880ea08b25f740a /tests/test/toperator93.pp
parent62a1b530781fb75b935bb40c2a2a10b7b0944d62 (diff)
downloadfpc-6432b512726f0b3167ec916c5cf67cf3dfbd922a.tar.gz
Merged revision(s) 47634, 47655 from trunk:
* fix for Mantis #38145: allow overloading of assignment operators that return ShortStrings with a specific size + 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... :/ ........ * with the recent ShortString changes this test is no longer needed as it was added exactly to check the condition I removed, so disable it for 3.2.1 and newer (as I want to merge these changes back to fixes) ........ git-svn-id: https://svn.freepascal.org/svn/fpc/branches/fixes_3_2@49055 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/test/toperator93.pp')
-rw-r--r--tests/test/toperator93.pp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test/toperator93.pp b/tests/test/toperator93.pp
new file mode 100644
index 0000000000..de3b37b015
--- /dev/null
+++ b/tests/test/toperator93.pp
@@ -0,0 +1,27 @@
+{ %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.