summary refs log tree commit diff stats
path: root/tests/effects/teffects17.nim
blob: 5e6b838962d15106fc19f13c4113cfe7de331462 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
discard """
action: compile
errormsg: "writeSomething(\"a\") has an illegal effect: WriteIO"
line: 17
"""

type
  IO = object of RootEffect ## input/output effect
  ReadIO = object of IO     ## input effect
  WriteIO = object of IO    ## output effect

proc readSomething(): string {.tags: [ReadIO].} = ""
proc writeSomething(msg: string): void {.tags: [WriteIO].} = echo msg

proc illegalEffectNegation() {.forbids: [WriteIO], tags: [ReadIO, WriteIO].} =
  echo readSomething()
  writeSomething("a")