JuliaCollections / JuliaCollections/FunctionalCollections.jl

Building PersistentHashMap through in-line for loop has different behavior than Dict

Open
#63 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

The code below throws an error BoundsError: attempt to access 1-element Array{Float64,1} at index [2], which seems to be a bug. When in the same code PersistentHashMap is replaced with Dict, the code works as expected.

function update()
    
    idx = 1

    a = Dict(:a=>0.)

    vec = [2.]

    results_cases = PersistentHashMap(
        case_key => 
            begin
                @info " " idx
                idx += 1
                vec[idx-1]
            end
         for (case_key,case) in a
    )

    return results_cases

end

update()

(I realize this code in and of itself does not make sense, however, it's part of a bigger piece of code where this kind of code is needed. Regardless this seems like a bug that should be fixed)

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

Start with the reproducer in the issue and compare PersistentHashMap construction with the equivalent Dict construction, focusing on the inline for-loop evaluation and indexing behavior. The issue is done when the reproducer no longer raises the BoundsError and PersistentHashMap behaves consistently with Dict for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.