diff --git a/compiler/symtable.pas b/compiler/symtable.pas index dbcf57f57a..60fcacbe31 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -1847,11 +1847,15 @@ implementation var st:Tsymtable; sym:Tprocsym; sv:cardinal; - besteq:tequaltype; - + curreq, + besteq : tequaltype; + currpd, + bestpd : tprocdef; begin st:=symtablestack; sv:=getspeedvalue('assign'); + besteq:=te_incompatible; + bestpd:=nil; while st<>nil do begin sym:=Tprocsym(st.speedsearch('assign',sv)); @@ -1861,12 +1865,18 @@ implementation internalerror(200402031); { if the source type is an alias then this is only the second choice, if you mess with this code, check tw4093 } - search_assignment_operator:=sym.search_procdef_assignment_operator(from_def,to_def,besteq); - if (search_assignment_operator<>nil) and (besteq=te_exact) then - break; + currpd:=sym.search_procdef_assignment_operator(from_def,to_def,curreq); + if curreq>besteq then + begin + besteq:=curreq; + bestpd:=currpd; + if (besteq=te_exact) then + break; + end; end; st:=st.next; end; + result:=bestpd; end; function searchsystype(const s: stringid; var srsym: ttypesym): boolean;