fixes generic types sink T cannot be inferred for passed arguments (#24761)

Otherwise, `sink T` is kept as it is. This PR treats sink types as its
base types for the arguments. So the concept would match both cases

Required by https://github.com/nim-lang/Nim/pull/24724
This commit is contained in:
ringabout
2025-03-13 00:31:19 +08:00
committed by GitHub
parent 4f32624641
commit 9ebfa7973a
2 changed files with 21 additions and 2 deletions

View File

@@ -1234,9 +1234,10 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
else:
var candidate = f
case f.kind
let fType = f.skipTypes({tySink})
case fType.kind
of tyGenericParam:
var prev = lookup(c.bindings, f)
var prev = lookup(c.bindings, fType)
if prev != nil: candidate = prev
of tyFromExpr:
let computedType = tryResolvingStaticExpr(c, f.n).typ

View File

@@ -0,0 +1,18 @@
type
Map[K, V] = concept m, var mvar
m[K] is V
m[K] = V
Table[K, V] = object
proc `[]=`[K, V](m: Table[K, V], x: sink K, y: sink V) =
let s = x
proc `[]`[K, V](m: Table[K, V], x: sink K): V =
let s = x
proc bat[K, V](x: Map[K, V]): V =
let m = x
var s = Table[int, string]()
discard bat(s)