Skip to content

Commit

Permalink
fix nim-lang#13310, Deque misbehaves on VM
Browse files Browse the repository at this point in the history
  • Loading branch information
narimiran committed Mar 11, 2020
1 parent 2f55765 commit 2884bc1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/pure/collections/deques.nim
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ 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 items(deq):
n[i] = x
inc i
deq.data = move(n)
deq.mask = cap * 2 - 1
Expand Down Expand Up @@ -569,3 +569,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()

0 comments on commit 2884bc1

Please sign in to comment.