teffects15.nim 433 B

12345678910111213141516171819
  1. discard """
  2. action: compile
  3. errormsg: "method1(c) has an illegal effect: IO"
  4. line: 18
  5. """
  6. type
  7. IO = object ## input/output effect
  8. CustomObject* = object of RootObj
  9. text: string
  10. method method1(obj: var CustomObject): string {.tags: [IO].} = obj.text & "."
  11. method method2(obj: var CustomObject): string = obj.text & ":"
  12. proc noIO() {.forbids: [IO].} =
  13. var c = CustomObject(text: "a")
  14. echo c.method2()
  15. echo c.method1()