diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index d801f67902..6597cbc798 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1711,7 +1711,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, if tfExplicitCallConv in target.flags and target.callConv != effectiveArgType.callConv: return isNone - put(c, f, a) + if doBind: put(c, f, a) return isGeneric else: return isNone diff --git a/tests/lookups/issue_23172/m23172.nim b/tests/lookups/issue_23172/m23172.nim new file mode 100644 index 0000000000..36af48761c --- /dev/null +++ b/tests/lookups/issue_23172/m23172.nim @@ -0,0 +1,6 @@ +type + Foo* = object + Bar* = object + +func `$`*(x: Foo | Bar): string = + "X" diff --git a/tests/lookups/t23172.nim b/tests/lookups/t23172.nim new file mode 100644 index 0000000000..9edf9905a4 --- /dev/null +++ b/tests/lookups/t23172.nim @@ -0,0 +1,9 @@ +import issue_23172/m23172 + +type FooX = distinct Foo + +func `$`*(x: FooX): string = + $m23172.Foo(x) + +var a: FooX +doAssert $a == "X"