Browse Source

Merged revisions 10957 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r10957 | florian | 2008-05-12 14:45:55 +0200 (Mon, 12 May 2008) | 2 lines

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

git-svn-id: branches/fixes_2_2@10980 -

florian 17 năm trước cách đây
mục cha
commit
970afaa125
3 tập tin đã thay đổi với 37 bổ sung0 xóa
  1. 1 0
      .gitattributes
  2. 12 0
      compiler/htypechk.pas
  3. 24 0
      tests/webtbs/tw11288.pp

+ 1 - 0
.gitattributes

@@ -7997,6 +7997,7 @@ tests/webtbs/tw1122.pp svneol=native#text/plain
 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/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

@@ -1974,6 +1974,7 @@ implementation
         pdoper   : tprocdef;
         releasecurrpt : boolean;
         cdoptions : tcompare_defs_options;
+        n : tnode;
 
     {$ifopt r+}{$define ena_rq}{$q-}{$r-}{$endif}
       const
@@ -2137,6 +2138,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.