blob: 9cabb35a2c652b75e5d317b4970895a30b72c7c5 (
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
|
block: # `.noSideEffect`
func foo(bar: proc(): int): int = bar()
var count = 0
proc fn1(): int = 1
proc fn2(): int = (count.inc; count)
template accept(body) =
doAssert compiles(block:
body)
template reject(body) =
doAssert not compiles(block:
body)
accept:
func fun1() = discard foo(fn1)
reject:
func fun1() = discard foo(fn2)
var foo2: type(foo) = foo
accept:
func main() = discard foo(fn1)
reject:
func main() = discard foo2(fn1)
|