Browse Source

* compare constant sets correctly while choosing an overloaded procedure, resolves #11288

git-svn-id: trunk@10957 -
florian 17 years ago
parent
commit
8306eb4753
3 changed files with 37 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 12 0
      compiler/htypechk.pas
  3. 24 0
      tests/webtbs/tw11288.pp

+ 1 - 0
.gitattributes

@@ -8202,6 +8202,7 @@ tests/webtbs/tw1123.pp svneol=native#text/plain
 tests/webtbs/tw1124.pp svneol=native#text/plain
 tests/webtbs/tw11254.pp svneol=native#text/plain
 tests/webtbs/tw11255.pp svneol=native#text/plain
+tests/webtbs/tw11288.pp svneol=native#text/plain
 tests/webtbs/tw1132.pp svneol=native#text/plain
 tests/webtbs/tw1133.pp svneol=native#text/plain
 tests/webtbs/tw1152.pp svneol=native#text/plain

+ 12 - 0
compiler/htypechk.pas

@@ -1952,6 +1952,7 @@ implementation
         pdoper   : tprocdef;
         releasecurrpt : boolean;
         cdoptions : tcompare_defs_options;
+        n : tnode;
 
     {$ifopt r+}{$define ena_r}{$r-}{$endif}
     {$ifopt q+}{$define ena_q}{$q-}{$endif}
@@ -2111,6 +2112,17 @@ implementation
                        objdef:=objdef.childof;
                      end;
                  end
+               { compare_defs_ext compares sets and array constructors very poorly because
+                 it has too little information. So we do explicitly a detailed comparisation,
+                 see also bug #11288 (FK)
+               }
+               else if (def_to.typ=setdef) and is_array_constructor(currpt.left.resultdef) then
+                 begin
+                   n:=currpt.left.getcopy;
+                   arrayconstructor_to_set(n);
+                   eq:=compare_defs_ext(n.resultdef,def_to,n.nodetype,convtype,pdoper,cdoptions);
+                   n.free;
+                 end
               else
               { generic type comparision }
                begin

+ 24 - 0
tests/webtbs/tw11288.pp

@@ -0,0 +1,24 @@
+program project1;
+
+{$mode delphi}
+
+type
+  TEnum1 = (en1, en2);
+  TEnum2 = (en3, en4);
+
+  TSet1 = set of TEnum1;
+  TSet2 = set of TEnum2;
+
+procedure DoSomethingWithSet(ASet: TSet1); overload;
+begin
+
+end;
+
+procedure DoSomethingWithSet(ASet: TSet2); overload;
+begin
+
+end;
+
+begin
+  DoSomethingWithSet([en1]);
+end.