teffects14.nim 363 B

12345678910111213141516
  1. discard """
  2. action: compile
  3. errormsg: "func1() has an illegal effect: IO"
  4. line: 15
  5. """
  6. type IO = object ## input/output effect
  7. proc func1(): string {.tags: [IO].} = discard
  8. proc func2(): string = discard
  9. proc no_IO_please() {.forbids: [IO].} =
  10. # this is OK because it didn't define any tag:
  11. discard func2()
  12. # the compiler prevents this:
  13. let y = func1()