summary refs log tree commit diff stats
path: root/tests/effects/tstrict_effects3.nim
blob: 4cc46154940b68a2ec0e4dbe42a8e07a6a7fe800 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
discard """
  action: compile
"""

{.push warningAsError[Effect]: on.}

{.experimental: "strictEffects".}

proc fn(a: int, p1, p2: proc()) {.effectsOf: p1.} =
  if a == 7:
    p1()
  if a<0:
    raise newException(ValueError, $a)

proc main() {.raises: [ValueError].} =
  fn(1, proc()=discard, proc() = raise newException(IOError, "foo"))
main()

# bug #19159

import macros

func mkEnter() =
  template helper =
    discard
  when defined pass:
    helper()
  else:
    let ast = getAst(helper())