summary refs log tree commit diff stats
path: root/tests/views
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-06-19 21:23:51 +0800
committerGitHub <noreply@github.com>2023-06-19 15:23:51 +0200
commit2054f1c3a9c78ac13593e90845807e9e64f22553 (patch)
tree98b85659fe896262388340ce89e8440d3d7be731 /tests/views
parent2bb7277a616b2ddbcc10a0e2eb1940f6b0b401cb (diff)
downloadNim-2054f1c3a9c78ac13593e90845807e9e64f22553.tar.gz
fixes #22117; View types lifetime tracking does not work with defer (#22121)
Diffstat (limited to 'tests/views')
-rw-r--r--tests/views/tviews1.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/views/tviews1.nim b/tests/views/tviews1.nim
index bf70e70c3..6662e3e5a 100644
--- a/tests/views/tviews1.nim
+++ b/tests/views/tviews1.nim
@@ -93,3 +93,15 @@ block: # bug #21674
     foo(x)
 
   main()
+
+block: # bug #22117
+  proc main: int =
+    var a = 10
+    defer: discard a # extend a's lifetime
+
+    var aref: var int = a
+      #└──── 'aref' borrows from location 'a' which does not live long enough
+
+    result = aref
+
+  doAssert main() == 10