diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-09-27 22:23:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-27 22:23:31 +0200 |
commit | 576fece90967ed2a6209c18ca839f30c751f4332 (patch) | |
tree | 2a76def9f4da47d51a780519b1dd4c8a052981aa /tests | |
parent | cdf9ac675b4348a7b5239186637c54920bb92619 (diff) | |
download | Nim-576fece90967ed2a6209c18ca839f30c751f4332.tar.gz |
fixes 'lent T' inside object constructor [backport] (#18911)
* fixes 'lent T' inside object constructor [backport] * progress
Diffstat (limited to 'tests')
-rw-r--r-- | tests/views/tviews1.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/views/tviews1.nim b/tests/views/tviews1.nim index 3dbf664fc..ced487ce8 100644 --- a/tests/views/tviews1.nim +++ b/tests/views/tviews1.nim @@ -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() |