JuliaArrays / JuliaArrays/StaticArrays.jl
Confusing display of zero-element SVector
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
SVector{0, T}() displays in REPL as T[], indicating that it's the same object as if i created T[], even if the object itself is different:
julia> SVector{0, Float32}()
Float32[]
julia> about(Float32[])
0-element Vector{Float32} (mutable) (<: DenseVector{Float32} <: AbstractVector{Float32} <:Any), occupies 24B directly (referencing 40B in total, holding 0B of data)
ref::MemoryRef{Float32} 16B «struct» MemoryRef{Float32}(Ptr{No … fb5a68cf5f0), Float32[])
size::Tuple{Int64} 8B «struct» (0,)
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
16B 8B
Float32 contents exist on the CPU within the ref::MemoryRef from 0x00007fb5a68cf5f0 to 0x00007fb5a68cf5f0.
0 items
in
0 bytes
julia> about(SVector{0, Float32}())
0-element SVector{0, Float32} with indices SOneTo(0) (<: StaticArray{Tuple{0}, Float32, 1}<: AbstractVector{Float32} <: Any), occupies 0B.
singleton
julia>
Otherwise SVectors display like this:
SVector(0.0)
1-element SVector{1, Float64} with indices SOneTo(1):
0.0
So maybe the proper display for zero-element SVector would be something like:
SVector{0, T}()
0-element SVector{1, T} with indices SOneTo(0)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the zero-element SVector and Vector outputs in the Julia REPL, then trace the display entry point used for SVector values. Done means the zero-element SVector is visibly distinguished from an ordinary T[] while non-empty SVector display remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100