blob: 027b4647413a91e9a69e0f3f9ab2169205659d24 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
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())
# bug #6559
type
SafeFn = proc (): void {. raises: [] }
proc ok() {. raises: [] .} = discard
proc fail() {. raises: [] .}
let f1 : SafeFn = ok
let f2 : SafeFn = fail
proc fail() = discard
f1()
f2()
|