JuliaArrays / JuliaArrays/StaticArrays.jl

map SOneTo to arrays? 🤷‍♀️

Open
#855 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

This causes https://github.com/fonsp/Pluto.jl/issues/458

MWE:

julia> using StaticArrays

julia> s = SA[1,2,3];

julia> i = eachindex(s)
SOneTo(3)

julia> map(i) do k
           []
       end
ERROR: setindex!() with non-isbitstype eltype is not supported by StaticArrays. Consider using SizedArray.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] setindex! at /home/fons/.julia/packages/StaticArrays/LJQEe/src/MArray.jl:99 [inlined]
 [3] collect_to_with_first!(::MArray{Tuple{3},Array{Any,1},1,3}, ::Array{Any,1}, ::Base.Generator{SOneTo{3},var"#3#4"}, ::Int64) at ./array.jl:709
 [4] _collect(::SOneTo{3}, ::Base.Generator{SOneTo{3},var"#3#4"}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at ./array.jl:704
 [5] collect_similar(::SOneTo{3}, ::Base.Generator{SOneTo{3},var"#3#4"}) at ./array.jl:628
 [6] map(::Function, ::SOneTo{3}) at ./abstractarray.jl:2162
 [7] top-level scope at REPL[6]:1

Note that this map is fine:

julia> map(i) do k
           2
       end
3-element MArray{Tuple{3},Int64,1,3} with indices SOneTo(3):
 2
 2
 2

Julia 1.5.2, StaticArrays v0.12.5

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 by rerunning the Julia MWE and reading the collection path in array.jl and abstractarray.jl, along with the StaticArrays behavior shown in src/MArray.jl. Compare the failing map that returns [] with the scalar-returning map; done means the reported non-isbits collection case has defined, tested behavior without regressing the working case.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.