fixes 'lent T' inside object constructor [backport] (#18911)

* fixes 'lent T' inside object constructor [backport]

* progress
This commit is contained in:
Andreas Rumpf 2021-09-27 22:23:31 +02:00 • committed by GitHub
commit 576fece909
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View file

@ -49,3 +49,20 @@ type
let s1 = @[1,3,4,5,6]
var test = F(oa: toOpenArray(s1, 0, 2))
echo test
type
Foo = object
x: string
y: seq[int]
data: array[10000, byte]
View[T] = object
x: lent T
proc mainB =
let f = Foo(y: @[1, 2, 3])
let foo = View[Foo](x: f)
assert foo.x.x == ""
assert foo.x.y == @[1, 2, 3]
mainB()