Skip to content

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

@mopg

Description

@mopg

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions