fixes #10942. Lent T bug (#10946)

* fixes #10942

* add test

* bug build
This commit is contained in:
cooldome 2019-04-03 14:55:53 +01:00 • committed by Andreas Rumpf
commit dc2986789b
5 changed files with 54 additions and 16 deletions

25
tests/types/tlent_var.nim Normal file
View file

@ -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)))