Skip to content

Commit

Permalink
tests: add a test case to tclosure
Browse files Browse the repository at this point in the history
  • Loading branch information
zerbina committed Aug 21, 2024
1 parent 8d9c526 commit d4e0bca
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/lang_callable/closure/tclosure.nim
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,24 @@ block close_over_compile_time_loc:
static:
p()

block close_over_compile_time_loc_2:
# nested non-compile-time-only procedures can close over locals of compile-
# time-only procedures
proc p() {.compileTime.} =
var x = 0
proc inner(cmp: int) = # `inner` is explicitly not compile-time-only
proc innerInner(cmp: int) =
inc x
doAssert x == cmp

innerInner(cmp)

inner(1)
inner(2)

static:
p()

template test(body: untyped) {.dirty.} =
## Tests that `body` works when placed in:
## - a normal procedure
Expand Down

0 comments on commit d4e0bca

Please sign in to comment.