From 4886534ed3bb1eedcb2d20bdab35bb79afc6b82d Mon Sep 17 00:00:00 2001 From: Ryan McConnell Date: Sat, 6 Jan 2024 05:50:09 +0000 Subject: [PATCH] Fixes #23172 (#23173) #23172 (cherry picked from commit a4f3bf374238df96f0982b7106e3702da6b485b1) --- compiler/sigmatch.nim | 2 +- tests/lookups/issue_23172/m23172.nim | 6 ++++++ tests/lookups/t23172.nim | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/lookups/issue_23172/m23172.nim create mode 100644 tests/lookups/t23172.nim 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"