diff options
author | cooldome <cdome@bk.ru> | 2019-04-03 14:55:53 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-04-03 15:55:53 +0200 |
commit | dc2986789b703300ac0680a10004f77453b146c3 (patch) | |
tree | 4eb1e05f057f855b6caf719c906e6591dfda3655 /tests | |
parent | 734da9544dda5a546a8add580499519be39f5591 (diff) | |
download | Nim-dc2986789b703300ac0680a10004f77453b146c3.tar.gz |
fixes #10942. Lent T bug (#10946)
* fixes #10942 * add test * bug build
Diffstat (limited to 'tests')
-rw-r--r-- | tests/types/tlent_var.nim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/types/tlent_var.nim b/tests/types/tlent_var.nim new file mode 100644 index 000000000..491f6fde8 --- /dev/null +++ b/tests/types/tlent_var.nim @@ -0,0 +1,25 @@ +discard """ + output: '''''' +""" + +type + MyObj = object + a: int + +proc test_lent(x: MyObj): lent int = + x.a + +proc test_var(x: var MyObj): var int = + x.a + +var x = MyObj(a: 5) + +doAssert: test_var(x).addr == x.a.addr +doAssert: test_lent(x).unsafeAddr == x.a.addr + +proc varProc(x: var int) = + x = 100 + +doAssert: not compiles(test_lent(x) = 1) +doAssert: not compiles(varProc(test_lent(x))) + |