mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-15 23:54:19 +00:00
* fix #13310, Deque misbehaves on VM * use 'when nimVM'
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user