Skip to content

map SOneTo to arrays? πŸ€·β€β™€οΈΒ #855

Open
@fonsp

Description

@fonsp

This causes fonsp/Pluto.jl#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions