mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-02 09:58:01 +00:00
fixes #25553
(cherry picked from commit 4566ffaca9)
This commit is contained in:
@@ -1673,7 +1673,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
||||
|
||||
let roota = if skipBoth or deptha > depthf: a.skipGenericAlias else: a
|
||||
let rootf = if skipBoth or depthf > deptha: f.skipGenericAlias else: f
|
||||
|
||||
|
||||
if f.isConcept:
|
||||
result = enterConceptMatch(c, rootf, roota, flags)
|
||||
elif a.kind == tyGenericInst:
|
||||
@@ -2187,9 +2187,9 @@ proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate,
|
||||
result.typ() = errorType(c)
|
||||
else:
|
||||
result.typ() = f.skipTypes({tySink})
|
||||
# keep varness
|
||||
# keep varness, but don't wrap lent types with var
|
||||
if arg.typ != nil and arg.typ.kind == tyVar:
|
||||
result.typ() = toVar(result.typ, tyVar, c.idgen)
|
||||
result.typ() = toVar(result.typ.skipTypes({tyLent}), tyVar, c.idgen)
|
||||
# copy the tfVarIsPtr flag
|
||||
result.typ.flags = arg.typ.flags
|
||||
else:
|
||||
|
||||
@@ -23,3 +23,18 @@ proc varProc(x: var int) =
|
||||
doAssert: not compiles(test_lent(x) = 1)
|
||||
doAssert: not compiles(varProc(test_lent(x)))
|
||||
|
||||
type X = tuple[a: int, b: int]
|
||||
|
||||
type ArrayBuf*[N: static int, T] = object
|
||||
buf*: array[N, T]
|
||||
|
||||
var v: ArrayBuf[32, X]
|
||||
|
||||
|
||||
# proc `[]`*[N, T](b: var ArrayBuf[N, T], i: BackwardsIndex): lent T = # works
|
||||
# b.buf[i]
|
||||
|
||||
template `[]`*[N, T](b: var ArrayBuf[N, T], i: BackwardsIndex): lent T =
|
||||
b.buf[i]
|
||||
|
||||
doAssert $v[^4] == "(a: 0, b: 0)"
|
||||
|
||||
Reference in New Issue
Block a user