summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2020-03-11 17:30:36 +0100
committerGitHub <noreply@github.com>2020-03-11 17:30:36 +0100
commit70bd41dae08a7ba9a9e8f19a935bee26b689d00d (patch)
tree0b92e884a058790e684c5fd172a55269806fc90d /lib
parent281e02fc797ad98013ab29525256ba2ffdaf96a7 (diff)
downloadNim-70bd41dae08a7ba9a9e8f19a935bee26b689d00d.tar.gz
fix #13310, Deque misbehaves on VM (#13625)
* fix #13310, Deque misbehaves on VM
* use 'when nimVM'
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/collections/deques.nim17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/pure/collections/deques.nim b/lib/pure/collections/deques.nim
index 1aa525bd6..77579a52b 100644
--- a/lib/pure/collections/deques.nim
+++ b/lib/pure/collections/deques.nim
@@ -274,8 +274,9 @@ proc expandIfNeeded[T](deq: var Deque[T]) =
   if unlikely(deq.count >= cap):
     var n = newSeq[T](cap * 2)
     var i = 0
-    for x in mitems(deq): # don't use copyMem because of the GC and because it's slower.
-      n[i] = move(x)
+    for x in mitems(deq):
+      when nimVM: n[i] = x # workaround for VM bug
+      else: n[i] = move(x)
       inc i
     deq.data = move(n)
     deq.mask = cap * 2 - 1
@@ -569,3 +570,15 @@ when isMainModule:
   foo(2, 1)
   foo(1, 5)
   foo(3, 2)
+
+  import sets
+  block t13310:
+    proc main() =
+      var q = initDeque[HashSet[int16]](2)
+      q.addFirst([1'i16].toHashSet)
+      q.addFirst([2'i16].toHashSet)
+      q.addFirst([3'i16].toHashSet)
+      assert $q == "[{3}, {2}, {1}]"
+
+    static:
+      main()