basic 'lent T' test works

This commit is contained in:
Andreas Rumpf 2018-01-21 03:04:22 +01:00
commit c99f952dfb
4 changed files with 36 additions and 16 deletions

View file

@ -0,0 +1,17 @@
discard """
cmd: "nim c --newRuntime $file"
output: "1"
"""
proc viewInto(a: array[4, string]): lent string =
result = a[0]
proc passToVar(x: var string) =
discard
proc main =
let x = ["1", "2", "3", "4"]
echo viewInto(x)
doAssert(not compiles(passToVar(viewInto(x))))
main()