Skip to content

Commit

Permalink
closes #14216; add testcase (#20733)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Nov 2, 2022
1 parent 841d9d5 commit 87f7f50
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/effects/teffectsmisc.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
discard """
output: '''
printing from adder
'''
"""

import std/sugar

block:
proc makeAdder(a: int): (int) -> void =
proc discard_adder(x: int) {.closure.} =
discard a + x

proc echo_adder(x: int) {.closure.} =
echo("printing from adder")

if a > 0:
discard_adder
else:
echo_adder

let newAdder = makeAdder(0)
newAdder(5)

block:
proc makeAdder(a: int): (int) -> void =
proc discard_adder(x: int) {.closure.} =
discard a + x

proc echo_adder(x: int) {.closure.} =
echo("printing from adder")

if a > 0:
echo_adder
else:
discard_adder

let newAdder = makeAdder(0)
newAdder(5)

0 comments on commit 87f7f50

Please sign in to comment.