From 780b468bbe6aaca76f66b09c42b492dfda2ad191 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sat, 23 May 2026 10:30:54 +0800 Subject: [PATCH] fix: enhance generic parameter matching in typeRel function --- compiler/sigmatch.nim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 0d6b0b9ab2..496e52ad7b 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1757,10 +1757,13 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, let ff = last(f) if ff != nil: result = typeRel(c, ff, a, flags) - if result == isNone and a.kind == tyGenericInst: + if result == isNone and a.kind == tyGenericInst and trBindGenericParam in flags: var depth = -1 - # Generic constraints like `F: Future` can miss in `last(f)` when the - # actual type inherits from a concrete generic instantiation. + # Generic-parameter constraints like `F: Future` can miss in `last(f)` + # when the actual type inherits from a concrete generic instantiation. + # Keep this fallback scoped to generic-parameter matching so typedesc + # overloads such as `type Future[T]` still prefer more specific + # descendants like `InternalRaisesFuture[T, E]`. if isGenericSubtype(c, a, f, depth, f) and depth > 0: var askip = skippedNone let aobj = a.skipToObject(askip)