Skip to content

zero-length MVector to SVector conversion fails (type info is lost) #782

@tpapp

Description

@tpapp
julia> using StaticArrays

julia> m = MVector{0,Int}()
0-element MArray{Tuple{0},Int64,1,0} with indices SOneTo(0)

julia> SVector(m)
ERROR: UndefVarError: T not defined
Stacktrace:
 [1] SArray{Tuple{0},T,1,0} where T(::Tuple{}) at /home/tamas/.julia/packages/StaticArrays/mlIi1/src/SVector.jl:19
 [2] SArray at /home/tamas/.julia/packages/StaticArrays/mlIi1/src/SVector.jl:18 [inlined]
 [3] SArray{Tuple{S},T,1,S} where T where S(::MArray{Tuple{0},Int64,1,0}) at /home/tamas/.julia/packages/StaticArrays/mlIi1/src/convert.jl:5
 [4] top-level scope at REPL[32]:1
 [5] eval(::Module, ::Any) at ./boot.jl:331
 [6] eval_user_input(::Any, ::REPL.REPLBackend) at /home/tamas/src/julia-1.4/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [7] run_backend(::REPL.REPLBackend) at /home/tamas/.julia/packages/Revise/MgvIv/src/Revise.jl:1023
 [8] top-level scope at none:0

I am happy to make a PR, just let me know what the preferred solution is. Maybe special-case 0-length? Or carry the type in the conversion?

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