JuliaArrays / JuliaArrays/StaticArrays.jl

Bug: SVector(SVector(x))===SVector(x)

Open
#1,340 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Constructing a length=1 SVector, with element a length=1 SVector results in one container being peeled away.

SVector(SVector(x))===SVector(x) forall x...

eltype(SVector(SVector(:a))) returns Symbol

SVector{1,SVector{1,Int64}}(SVector(1))
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type SVector{1, Int64}

That's with StaticArrays v1.9.16, but also StaticArrays v1.9.18

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 reproducing the nested length-1 SVector examples from the issue and inspect the SVector construction and conversion entry points they exercise. Done means SVector(SVector(x)) preserves the inner container, eltype remains SVector{1,typeof(x)}, and the explicitly typed construction no longer attempts to convert the inner value to its element type.

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
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.