2
0
Эх сурвалжийг харах

* when checking for the <dyn array> + <dyn array> overload then *both* sides need to be dynamic arrays
+ added test

Sven/Sarah Barth 4 өдөр өмнө
parent
commit
03eb9d0c0a

+ 2 - 1
compiler/htypechk.pas

@@ -528,7 +528,8 @@ implementation
                  { <dyn. array> + <dyn. array> is handled by the compiler }
                  if (m_array_operators in current_settings.modeswitches) and
                      (treetyp=addn) and
-                     (is_dynamic_array(ld) or is_dynamic_array(rd)) then
+                     (is_dynamic_array(ld) or is_array_constructor(ld)) and
+                     (is_dynamic_array(rd) or is_array_constructor(rd)) then
                     begin
                       allowed:=false;
                       exit;

+ 18 - 0
tests/test/tgeneric129.pp

@@ -0,0 +1,18 @@
+{ %NORUN }
+
+program tgeneric129;
+
+{$mode delphi}
+
+type
+  Vector<T> = record
+  public
+    class operator Add(const left: TArray<T>; const right: Vector<T>): Vector<T>; inline;
+  end;
+
+class operator Vector<T>.Add(const left: TArray<T>; const right: Vector<T>): Vector<T>;
+begin
+end;
+
+begin
+end.