From 8306eb4753730dcb1fe569bdeda3ba3a23ab3b5a Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 12 May 2008 12:45:55 +0000 Subject: [PATCH] * compare constant sets correctly while choosing an overloaded procedure, resolves #11288 git-svn-id: trunk@10957 - --- .gitattributes | 1 + compiler/htypechk.pas | 12 ++++++++++++ tests/webtbs/tw11288.pp | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/webtbs/tw11288.pp diff --git a/.gitattributes b/.gitattributes index f1492f56f2..8d13be7c6b 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/htypechk.pas b/compiler/htypechk.pas index 780b3a09c2..a257ac6359 100644 --- a/compiler/htypechk.pas +++ b/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 diff --git a/tests/webtbs/tw11288.pp b/tests/webtbs/tw11288.pp new file mode 100644 index 0000000000..770afa7ef1 --- /dev/null +++ b/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.