summary refs log tree commit diff stats
path: root/tests/lent
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2023-07-04 23:35:25 +0200
committerGitHub <noreply@github.com>2023-07-04 23:35:25 +0200
commit86ff37fab8656f7acd08fc9c3fa237f9e022dbf4 (patch)
treea2a4823c4038d43fd6e8ada7efe2bc36c4c4e3da /tests/lent
parent31ba1046fc91f110117b9e1cbd28d1afb4432060 (diff)
downloadNim-86ff37fab8656f7acd08fc9c3fa237f9e022dbf4.tar.gz
fixes #22138 (#22221)
Diffstat (limited to 'tests/lent')
-rw-r--r--tests/lent/tlent_from_var.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/lent/tlent_from_var.nim b/tests/lent/tlent_from_var.nim
index 912390dc1..d61ff6dc0 100644
--- a/tests/lent/tlent_from_var.nim
+++ b/tests/lent/tlent_from_var.nim
@@ -30,3 +30,23 @@ let x2 = x.byLentVar
 
 let xs2 = xs.byLentVar
 echo xs2
+
+# bug #22138
+
+type Xxx = object
+
+type
+  Opt[T] = object
+    case oResultPrivate*: bool
+    of false:
+      discard
+    of true:
+      vResultPrivate*: T
+
+func value*[T: not void](self: Opt[T]): lent T {.inline.} =
+  self.vResultPrivate
+template get*[T: not void](self: Opt[T]): T = self.value()
+
+method connect*(
+  self: Opt[(int, int)]) =
+  discard self.get()[0]