tfuncs_cannot_mutate_simple.nim 372 B

12345678910111213141516171819202122
  1. discard """
  2. errormsg: "'edit' can have side effects"
  3. nimout: '''an object reachable from 'x' is potentially mutated
  4. tfuncs_cannot_mutate_simple.nim(17, 4) the mutation is here'''
  5. line: 16
  6. """
  7. {.experimental: "strictFuncs".}
  8. # bug #15508
  9. type
  10. MyType = ref object
  11. data: string
  12. func edit(x: MyType) =
  13. x.data = "hello"
  14. let x = MyType()
  15. x.edit()
  16. echo x.data