fixes #21278; deques.shrink off ny one bug
This commit is contained in:
parent
4c74b9b54c
commit
b82b5d44af
2 changed files with 7 additions and 1 deletions
|
|
@ -440,7 +440,7 @@ proc shrink*[T](deq: var Deque[T], fromFirst = 0, fromLast = 0) =
|
|||
deq.head = (deq.head + 1) and deq.mask
|
||||
|
||||
for i in 0 ..< fromLast:
|
||||
destroy(deq.data[deq.tail])
|
||||
destroy(deq.data[(deq.tail - 1) and deq.mask])
|
||||
deq.tail = (deq.tail - 1) and deq.mask
|
||||
|
||||
dec deq.count, fromFirst + fromLast
|
||||
|
|
|
|||
|
|
@ -183,6 +183,12 @@ proc main() =
|
|||
clear(a)
|
||||
doAssert len(a) == 0
|
||||
|
||||
block: # bug #21278
|
||||
var a = [10, 20, 30, 40].toDeque
|
||||
|
||||
a.shrink(fromFirst = 0, fromLast = 1)
|
||||
doAssert $a == "[10, 20, 30]"
|
||||
|
||||
|
||||
static: main()
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue