JuliaCollections / JuliaCollections/FunctionalCollections.jl

`disj` of the last element of the set results in non-iterable collection

Open
#32 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
126
Forks
33
PR merge metrics
No merged PRs in 30d

Description

To reproduce:

using FunctionalCollections

s = pset(1,2,3)
# => PersistentSet{Int64}(2, 3, 1)
disj(s, 1)

will output:

PersistentSet{Int64}(Error showing value of type FunctionalCollections.PersistentSet{Int64}:
ERROR: MethodError: no method matching next(::FunctionalCollections.SparseNode{FunctionalCollections.PersistentArrayMap{Int64,Void}}, ::Array{Any,1})
Closest candidates are:
  next(::SimpleVector, ::Any) at essentials.jl:171
  next(::Base.MethodList, ::Any) at reflection.jl:260
  next(::IntSet, ::Any) at intset.jl:187
  ...
 in next(::FunctionalCollections.PersistentHashMap{Int64,Void}, ::Tuple{Array{Pair{Int64,Void},1},Array{Any,1}}) at C:\Users\alexe_000\.julia\v0.5\FunctionalCollections\src\PersistentMap.jl:173
 in next(::FunctionalCollections.PersistentHashMap{Int64,Void}, ::Tuple{Array{Pair{Int64,Void},1},Array{Int64,1}}) at C:\Users\alexe_000\.julia\v0.5\FunctionalCollections\src\PersistentMap.jl:174
 in next at .\generator.jl:25 [inlined]
 in collect_to!(::Array{Int64,1}, ::Base.Generator{FunctionalCollections.PersistentHashMap{Int64,Void},FunctionalCollections.##30#31}, ::Int64, ::Tuple{Array{Pair{Int64,Void},1},Array{Int64,1}}) at .\array.jl:340
 in collect_to_with_first!(::Array{Int64,1}, ::Int64, ::Base.Generator{FunctionalCollections.PersistentHashMap{Int64,Void},FunctionalCollections.##30#31}, ::Tuple{Array{Pair{Int64,Void},1},Array{Int64,1}}) at .\array.jl:327
 in collect(::Base.Generator{FunctionalCollections.PersistentHashMap{Int64,Void},FunctionalCollections.##30#31}) at .\array.jl:308
 in show(::IOContext{Base.Terminals.TTYTerminal}, ::FunctionalCollections.PersistentSet{Int64}) at C:\Users\alexe_000\.julia\v0.5\FunctionalCollections\src\PersistentSet.jl:81
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::FunctionalCollections.PersistentSet{Int64}) at .\REPL.jl:132
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::FunctionalCollections.PersistentSet{Int64}) at .\REPL.jl:135
 in display(::FunctionalCollections.PersistentSet{Int64}) at .\multimedia.jl:143
 in print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at .\REPL.jl:154
 in print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at .\REPL.jl:139
 in (::Base.REPL.##22#23{Bool,Base.REPL.##33#42{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at .\REPL.jl:652
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at .\LineEdit.jl:1579
 in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at .\REPL.jl:903
 in run_repl(::Base.REPL.LineEditREPL, ::Base.##932#933) at .\REPL.jl:188
 in _start() at .\client.jl:360

So, the error happens only on output or when you try to collect or filter or other way iterate the collection. Taking length, on the other hand works.

Tested on: Windows 10, Julia 0.5, FunctionalCollections (master)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with disj(pset(1,2,3), 1), then inspect PersistentSet.jl around its show method and PersistentMap.jl around next at lines 173–174. Verify the resulting set can be displayed, collected, and filtered after removing the final element, while length still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.