Skip to content

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

@mobius-eng

Description

@mobius-eng

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions