summary refs log tree commit diff stats
path: root/tests/tuples
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-08-24 07:11:48 +0300
committerGitHub <noreply@github.com>2023-08-24 06:11:48 +0200
commit53d43e96716539d96e6a1e5f3926a3fe3a11e2dd (patch)
tree72cfa0912436848892c30608f3d2eb28aa2d6347 /tests/tuples
parent03f267c8013eca2830eb3deadda73ed08096ec12 (diff)
downloadNim-53d43e96716539d96e6a1e5f3926a3fe3a11e2dd.tar.gz
round out tuple unpacking assignment, support underscores (#22537)
* round out tuple unpacking assignment, support underscores

fixes #18710

* fix test messages

* use discard instead of continue

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests/tuples')
-rw-r--r--tests/tuples/ttuples_various.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/tuples/ttuples_various.nim b/tests/tuples/ttuples_various.nim
index 97bc70bd2..e392731d2 100644
--- a/tests/tuples/ttuples_various.nim
+++ b/tests/tuples/ttuples_various.nim
@@ -197,3 +197,15 @@ block: # bug #22054
 
   var v = A(field: (a: 1314))
   doAssert get(v)[0] == 1314
+
+block: # tuple unpacking assignment with underscore
+  var
+    a = 1
+    b = 2
+  doAssert (a, b) == (1, 2)
+  (a, _) = (3, 4)
+  doAssert (a, b) == (3, 2)
+  (_, a) = (5, 6)
+  doAssert (a, b) == (6, 2)
+  (b, _) = (7, 8)
+  doAssert (a, b) == (6, 7)