diff --git a/.gitattributes b/.gitattributes index 00bd21ac86..22002fc8fc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15223,6 +15223,7 @@ tests/webtbs/tw30443.pp svneol=native#text/plain tests/webtbs/tw3045.pp svneol=native#text/plain tests/webtbs/tw3048.pp svneol=native#text/plain tests/webtbs/tw30522.pp svneol=native#text/plain +tests/webtbs/tw30534.pp svneol=native#text/pascal tests/webtbs/tw30570.pp svneol=native#text/plain tests/webtbs/tw30572.pp svneol=native#text/plain tests/webtbs/tw3063.pp svneol=native#text/plain diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 310f8fa519..a9018b5a4f 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -275,20 +275,33 @@ implementation end else begin - { undefined defs or defs with generic constraints are - considered equal to everything } - if ( - (def_from.typ=undefineddef) or - assigned(tstoreddef(def_from).genconstraintdata) - ) or ( - (def_to.typ=undefineddef) or - assigned(tstoreddef(def_to).genconstraintdata) - ) then - begin - doconv:=tc_equal; - compare_defs_ext:=te_exact; - exit; - end; + { undefined defs are considered equal to everything } + if (def_from.typ=undefineddef) or + (def_to.typ=undefineddef) then + begin + doconv:=tc_equal; + compare_defs_ext:=te_exact; + exit; + end; + + { either type has constraints } + if assigned(tstoreddef(def_from).genconstraintdata) or + assigned(tstoreddef(def_to).genconstraintdata) then + begin + if def_from.typ<>def_to.typ then + begin + { not compatible anyway } + doconv:=tc_not_possible; + compare_defs_ext:=te_incompatible; + exit; + end; + + { one is definitely a constraint, for the other we don't + care right now } + doconv:=tc_equal; + compare_defs_ext:=te_exact; + exit; + end; end; { two specializations are considered equal if they specialize the same diff --git a/tests/webtbs/tw30534.pp b/tests/webtbs/tw30534.pp new file mode 100644 index 0000000000..609b37e632 --- /dev/null +++ b/tests/webtbs/tw30534.pp @@ -0,0 +1,18 @@ +{ %NORUN } + +{$MODE DELPHI} + +type + TSmartPtr = record + class operator Implicit(aValue: T): TSmartPtr; + end; + +class operator TSmartPtr.Implicit(aValue: T): TSmartPtr; +begin +end; + +var + sp: TSmartPtr; +begin + sp := nil; +end.