summary refs log tree commit diff stats
path: root/tests/tuples/ttuples_various.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-06-16 18:06:50 +0800
committerGitHub <noreply@github.com>2023-06-16 12:06:50 +0200
commit77beb152141f0efe4d5c93b784e42f973ba46551 (patch)
treeb3489ba32952b1dd5a00894face8a05803c0d4a0 /tests/tuples/ttuples_various.nim
parent0750210a508f34e9dcf26a64f4727dfe9ad9c98a (diff)
downloadNim-77beb152141f0efe4d5c93b784e42f973ba46551.tar.gz
fixes #22049; fixes #22054; implicit conversion keeps varness (#22097)
* fixes #22054; codegen for var tuples conv

* rethink fixes

* add test cases

* templates only

* fixes var tuples

* keep varness no matter what

* fixes typ.isNil

* make it work for generics

* restore isSubrange

* add a test case as requested
Diffstat (limited to 'tests/tuples/ttuples_various.nim')
-rw-r--r--tests/tuples/ttuples_various.nim26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/tuples/ttuples_various.nim b/tests/tuples/ttuples_various.nim
index dc060da1e..97bc70bd2 100644
--- a/tests/tuples/ttuples_various.nim
+++ b/tests/tuples/ttuples_various.nim
@@ -171,3 +171,29 @@ block tuple_with_seq:
     echo s
     (s, 7)
   t = test(t.a)
+
+block: # bug #22049
+  type A = object
+    field: tuple[a, b, c: seq[int]]
+
+  func value(v: var A): var tuple[a, b, c: seq[int]] =
+    v.field
+  template get(v: A): tuple[a, b, c: seq[int]] = v.value
+
+  var v = A(field: (@[1], @[2], @[3]))
+  var (a, b, c) = v.get()
+
+  doAssert a == @[1]
+  doAssert b == @[2]
+  doAssert c == @[3]
+
+block: # bug #22054
+  type A = object
+    field: tuple[a: int]
+
+  func value(v: var A): var tuple[a: int] =
+    v.field
+  template get(v: A): tuple[a: int] = v.value
+
+  var v = A(field: (a: 1314))
+  doAssert get(v)[0] == 1314