t19986.nim 708 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. discard """
  2. cmd: '''nim check --hints:off $file'''
  3. action: reject
  4. nimout: '''
  5. t19986.nim(19, 7) Error: 'foo' borrows from the immutable location 'a' and attempts to mutate it
  6. t19986.nim(28, 7) Error: 'foo' borrows from the immutable location 'a' and attempts to mutate it
  7. t19986.nim(37, 7) Error: 'foo' borrows from the immutable location 'a' and attempts to mutate it
  8. '''
  9. """
  10. {.experimental: "views".}
  11. type
  12. Object = object
  13. id: int
  14. proc foo() =
  15. let a = Object(id: 3)
  16. var foo: var Object = a
  17. foo.id = 777
  18. echo a
  19. foo()
  20. proc bar() =
  21. let a = "123"
  22. var foo: var string = a
  23. foo[0] = '7'
  24. echo a
  25. bar()
  26. proc main() =
  27. let a = 3
  28. var foo: var int = a
  29. foo = 777
  30. echo a
  31. main()