(cherry picked from commit 86ff37fab8)
This commit is contained in:
Andreas Rumpf
2023-07-04 23:35:25 +02:00
committed by narimiran
parent efa3479e4e
commit d80397c7d7
2 changed files with 27 additions and 2 deletions

View File

@@ -1634,7 +1634,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
elif a.len > 0 and a.lastSon == f:
# Needed for checking `Y` == `Addable` in the following
#[
type
type
Addable = concept a, type A
a + a is A
MyType[T: Addable; Y: static T] = object
@@ -1901,7 +1901,12 @@ proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate,
if result.typ == nil: internalError(c.graph.config, arg.info, "implicitConv")
result.add c.graph.emptyNode
result.add arg
if arg.typ != nil and arg.typ.kind == tyLent:
let a = newNodeIT(nkHiddenDeref, arg.info, arg.typ[0])
a.add arg
result.add a
else:
result.add arg
proc isLValue(c: PContext; n: PNode): bool {.inline.} =
let aa = isAssignable(nil, n)

View File

@@ -30,3 +30,23 @@ let x2 = x.byLentVar
let xs2 = xs.byLentVar
echo xs2
# bug #22138
type Xxx = object
type
Opt[T] = object
case oResultPrivate*: bool
of false:
discard
of true:
vResultPrivate*: T
func value*[T: not void](self: Opt[T]): lent T {.inline.} =
self.vResultPrivate
template get*[T: not void](self: Opt[T]): T = self.value()
method connect*(
self: Opt[(int, int)]) =
discard self.get()[0]