tbasic_lent_check.nim 294 B

123456789101112131415161718
  1. discard """
  2. cmd: "nim c --newRuntime $file"
  3. output: "1"
  4. """
  5. proc viewInto(a: array[4, string]): lent string =
  6. result = a[0]
  7. proc passToVar(x: var string) =
  8. discard
  9. proc main =
  10. let x = ["1", "2", "3", "4"]
  11. echo viewInto(x)
  12. doAssert(not compiles(passToVar(viewInto(x))))
  13. main()