tfuncs_cannot_mutate_simple.nim 361 B

123456789101112131415161718192021
  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(16, 4) the mutation is here'''
  5. """
  6. {.experimental: "strictFuncs".}
  7. # bug #15508
  8. type
  9. MyType = ref object
  10. data: string
  11. func edit(x: MyType) =
  12. x.data = "hello"
  13. let x = MyType()
  14. x.edit()
  15. echo x.data