teffects19.nim 605 B

123456789101112131415161718192021222324
  1. discard """
  2. action: compile
  3. errormsg: "type mismatch: got <proc (i: int){.gcsafe.}>"
  4. line: 23
  5. """
  6. type MyEffect = object
  7. type ProcType1 = proc (i: int): void {.forbids: [MyEffect].}
  8. type ProcType2 = proc (i: int): void
  9. proc caller1(p: ProcType1): void = p(1)
  10. proc caller2(p: ProcType2): void = p(1)
  11. proc effectful(i: int): void {.tags: [MyEffect].} = echo $i
  12. proc effectless(i: int): void {.forbids: [MyEffect].} = echo $i
  13. proc toBeCalled1(i: int): void = effectful(i)
  14. proc toBeCalled2(i: int): void = effectless(i)
  15. caller1(toBeCalled2)
  16. caller2(toBeCalled1)
  17. caller2(toBeCalled2)
  18. caller1(toBeCalled1)