JuliaArrays / JuliaArrays/StaticArrays.jl
`zero(::FieldVector{1})` errors with constructor method ambiguity
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
julia> struct Single{T} <: FieldVector{1,T}
x::T
end
julia> v = Single(1.0)
1-element Single{Float64} with indices SOneTo(1):
1.0
julia> zero(v)
ERROR: MethodError: Single{Float64}(::Tuple{Float64}) is ambiguous.
Candidates:
(var"#ctor-self#"::Type{Single{T}} where T)(x)
@ Main REPL[4]:2
(::Type{FA})(x::Tuple) where FA<:FieldArray
@ StaticArrays ~/.julia/packages/StaticArrays/9Yt0H/src/FieldArray.jl:2
Possible fix, define
Single{T}(::Tuple) where T
[...]
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
Start with the Julia REPL reproduction in the issue and inspect the FieldArray.jl constructor location shown in the error. Trace why zero(v) reaches two ambiguous Single{Float64}(...) methods, then confirm that the same example completes without a constructor ambiguity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100