Browse Source

* nil =/<> dyn. array is a valid expression, so isbinaryoperatoroverloadable needs to take care of it, resolves #39933

(cherry picked from commit 2396b36c21c58a00b1a2e49b288393470de5cf88)
florian 2 năm trước cách đây
mục cha
commit
19c2e948b9
2 tập tin đã thay đổi với 15 bổ sung1 xóa
  1. 2 1
      compiler/htypechk.pas
  2. 13 0
      tests/webtbs/tw39933.pp

+ 2 - 1
compiler/htypechk.pas

@@ -459,7 +459,8 @@ implementation
                              ) or
                              ) or
                              (
                              (
                                (lt=niln) and
                                (lt=niln) and
-                               (rd.typ in [procvardef,procdef,classrefdef]) and
+                               ((rd.typ in [procvardef,procdef,classrefdef]) or
+                                (is_dynamic_array(rd))) and
                                (treetyp in identity_operators)
                                (treetyp in identity_operators)
                              ) or
                              ) or
                              (
                              (

+ 13 - 0
tests/webtbs/tw39933.pp

@@ -0,0 +1,13 @@
+{ %norun }
+program Project1;
+
+{$mode delphi}
+
+var a: TArray<integer>;
+
+begin
+  writeln ( a = nil );
+  writeln ( a <> nil );
+  writeln ( nil = a );   // project1.lpr(10,17) Error: Operator is not overloaded: "Pointer" = "TArray$1$crc9F312717"
+  writeln ( nil <> a );  // project1.lpr(11,17) Error: Operator is not overloaded: "Pointer" = "TArray$1$crc9F312717"
+end.