* fixes #10942 * add test * bug build
This commit is contained in:
parent
734da9544d
commit
dc2986789b
5 changed files with 54 additions and 16 deletions
25
tests/types/tlent_var.nim
Normal file
25
tests/types/tlent_var.nim
Normal 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)))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue