JuliaCollections / FunctionalCollections.jl

Functional and persistent data structures for Julia
MIT License
124 stars 34 forks source link

Fix bug in pvec `pop` resulting in empty tail #64

Open georgematheos opened 4 years ago

georgematheos commented 4 years ago

When calling pop on a persistent vector with, eg., 33 elements, we have a tail of length 1. After this pop call, there was a bug where the resulting pvec had a tail of length 0 rather than a tail of length 32. This causes errors, for instance when calling iterate, which expects a nonempty tail. This PR fixes the behavior by adding a branch in pop function for when the tail length is currently 1 (in which case we make the new tail be pop(trie)).

georgematheos commented 4 years ago

(just added a test for this behavior)

codecov-commenter commented 4 years ago

Codecov Report

Merging #64 into master will increase coverage by 1.07%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #64      +/-   ##
==========================================
+ Coverage   77.30%   78.38%   +1.07%     
==========================================
  Files           7        7              
  Lines         379      384       +5     
==========================================
+ Hits          293      301       +8     
+ Misses         86       83       -3     
Impacted Files Coverage Δ
src/PersistentVector.jl 76.62% <100.00%> (+3.01%) :arrow_up:
src/BitmappedVectorTrie.jl 72.81% <0.00%> (+1.94%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2dd9b36...2bafd37. Read the comment docs.