Skip to content

Commit

Permalink
closes nim-lang#14216; add testcase (nim-lang#20733)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored and bung87 committed Jul 29, 2023
1 parent ca2f8f2 commit 4d0b953
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 4d0b953

Please sign in to comment.