Effects pragma

The effects pragma has been designed to assist the programmer with the effects analysis. It is a statement that makes the compiler output all inferred effects up to the effects’s position:

  1. proc p(what: bool) =
  2. if what:
  3. raise newException(IOError, "IO")
  4. {.effects.}
  5. else:
  6. raise newException(OSError, "OS")

The compiler produces a hint message that IOError can be raised. OSError is not listed as it cannot be raised in the branch the effects pragma appears in.