JuliaArrays / JuliaArrays/StaticArrays.jl
Inconsistencies with multi-argument constructors
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
Given that Scalar <: SArray, the behavior of
https://github.com/JuliaArrays/StaticArrays.jl/blob/552bc7596c1639d1f66bf781084d3961b36dbd53/src/Scalar.jl#L10
is inconsistent with
https://github.com/JuliaArrays/StaticArrays.jl/blob/552bc7596c1639d1f66bf781084d3961b36dbd53/src/convert.jl#L5
Fortunately, in a few cases there's a very welcome ambiguity error:
julia> sa = Scalar((1,))
Scalar{Int64}((1,))
julia> Scalar(sa)
ERROR: MethodError: Scalar{T} where T(::Scalar{T}) is ambiguous. Candidates:
(::Type{Scalar{T} where T})(a::AbstractArray{T,0} where T) in StaticArrays at /home/tim/.julia/dev/StaticArrays/src/Scalar.jl:11
(::Type{Scalar{T} where T})(a::AbstractArray) in StaticArrays at /home/tim/.julia/dev/StaticArrays/src/Scalar.jl:10
(::Type{SA})(a::StaticArray) where SA<:StaticArray in StaticArrays at /home/tim/.julia/dev/StaticArrays/src/convert.jl:4
Possible fix, define
Scalar{T} where T(::StaticArray{S,T,0} where T where S<:Tuple)
Stacktrace:
[1] top-level scope at none:0
but mostly this just silently does things differently for 0 dimensions than for any other dimension.
I don't think you can really have both. Can you choose which behavior you want to keep?
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
Read the constructor methods in src/Scalar.jl and src/convert.jl at the linked lines, then reproduce the Scalar((1,)) and Scalar(sa) examples in Julia. Resolve which multi-argument and conversion behavior should be retained, with consistent behavior for zero-dimensional and other-dimensional arrays as the completion criterion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100