teffects17.nim 501 B

123456789101112131415161718
  1. discard """
  2. action: compile
  3. errormsg: "writeSomething(\"a\") has an illegal effect: WriteIO"
  4. line: 17
  5. """
  6. type
  7. IO = object of RootEffect ## input/output effect
  8. ReadIO = object of IO ## input effect
  9. WriteIO = object of IO ## output effect
  10. proc readSomething(): string {.tags: [ReadIO].} = ""
  11. proc writeSomething(msg: string): void {.tags: [WriteIO].} = echo msg
  12. proc illegalEffectNegation() {.forbids: [WriteIO], tags: [ReadIO, WriteIO].} =
  13. echo readSomething()
  14. writeSomething("a")