summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2023-08-27 22:56:50 +0800
committerGitHub <noreply@github.com>2023-08-27 22:56:50 +0800
commit100eb6820c271bbd1c02a8e6a9001fc5a08a2637 (patch)
treeb95087ca5eb42826ab392de1a685158552f879e4
parent0b78b7f595ef96a9769e0d59167239c611b9857a (diff)
downloadNim-100eb6820c271bbd1c02a8e6a9001fc5a08a2637.tar.gz
close #9334 (#22565)
-rw-r--r--tests/closure/t9334.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/closure/t9334.nim b/tests/closure/t9334.nim
new file mode 100644
index 000000000..36a9a7d77
--- /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]