mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 18:34:43 +00:00
19
tests/closure/t9334.nim
Normal file
19
tests/closure/t9334.nim
Normal file
@@ -0,0 +1,19 @@
|
||||
discard """
|
||||
cmd: "nim $target --hints:off $options -r $file"
|
||||
nimout: '''@[1]
|
||||
@[1, 1]
|
||||
'''
|
||||
nimoutFull: true
|
||||
"""
|
||||
proc p(s: var seq[int]): auto =
|
||||
let sptr = addr s
|
||||
return proc() = sptr[].add 1
|
||||
|
||||
proc f =
|
||||
var data = @[1]
|
||||
p(data)()
|
||||
echo repr data
|
||||
|
||||
static:
|
||||
f() # prints [1]
|
||||
f() # prints [1, 1]
|
||||
Reference in New Issue
Block a user