From 100eb6820c271bbd1c02a8e6a9001fc5a08a2637 Mon Sep 17 00:00:00 2001 From: Bung Date: Sun, 27 Aug 2023 22:56:50 +0800 Subject: [PATCH] close #9334 (#22565) --- tests/closure/t9334.nim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/closure/t9334.nim diff --git a/tests/closure/t9334.nim b/tests/closure/t9334.nim new file mode 100644 index 0000000000..36a9a7d77c --- /dev/null +++ b/tests/closure/t9334.nim @@ -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]