diff options
author | gecko <geckojsc@gmail.com> | 2022-01-10 09:27:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-10 10:27:59 +0100 |
commit | 955040f0f1d4f9b2eab68c385fab9d4cfbef8ea5 (patch) | |
tree | 1b6f047674b1cc23c88e9ae43b2156b789c8cdf0 /lib/pure/collections | |
parent | b098546da051ed026e85a9f398e74c396c79a8ad (diff) | |
download | Nim-955040f0f1d4f9b2eab68c385fab9d4cfbef8ea5.tar.gz |
Fix `remove` on last node of singly-linked list [backport:1.6] (#19353)
Diffstat (limited to 'lib/pure/collections')
-rw-r--r-- | lib/pure/collections/lists.nim | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim index f7627ae67..d1de0ea67 100644 --- a/lib/pure/collections/lists.nim +++ b/lib/pure/collections/lists.nim @@ -739,6 +739,8 @@ proc remove*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]): bool {.disc if prev.next == nil: return false prev.next = n.next + if L.tail == n: + L.tail = prev # update tail if we removed the last node true proc remove*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = |