Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construction from SVector is ambiguous #216

Open
aplavin opened this issue Apr 21, 2024 · 1 comment
Open

Construction from SVector is ambiguous #216

aplavin opened this issue Apr 21, 2024 · 1 comment

Comments

@aplavin
Copy link

aplavin commented Apr 21, 2024

For example, Point2(SVector(1, 2)) throws:

MethodError: (GeometryBasics.Point2)(::StaticArraysCore.SVector{2, Int64}) is ambiguous.
Candidates:
(::Type{SV})(x::StaticArraysCore.StaticArray{Tuple{N}, T, 1} where {N, T}) where SV<:GeometryBasics.Point
@ GeometryBasics ~/.julia/packages/GeometryBasics/bLARu/src/fixed_arrays.jl:74
(GeometryBasics.Point{S})(x::AbstractVector{T}) where {S, T}
@ GeometryBasics ~/.julia/packages/GeometryBasics/bLARu/src/fixed_arrays.jl:34
(::Type{SA})(sa::StaticArraysCore.StaticArray) where SA<:StaticArraysCore.StaticArray
@ StaticArrays ~/.julia/packages/StaticArrays/EHHaF/src/convert.jl:170
(GeometryBasics.Point{S})(x::T) where {S, T}
@ GeometryBasics ~/.julia/packages/GeometryBasics/bLARu/src/fixed_arrays.jl:48
(T::Type{<:StaticArraysCore.StaticArray})(a::AbstractArray)
@ StaticArrays ~/.julia/packages/StaticArrays/EHHaF/src/convert.jl:174
Possible fix, define
(GeometryBasics.Point{S})(::StaticArraysCore.StaticArray{Tuple{N}, T, 1} where N) where {S, T}
@asinghvi17
Copy link
Contributor

asinghvi17 commented Apr 21, 2024

Ah, I think this is because Point2 is also a subtype of StaticArray. We would probably need to define that dispatch in the macro which generates the point definitions.

In this case, the fix would be GB.Point{N}(::SArray{Tuple{N}, T, 1}) where N = ... or so. I've abbreviated a bit but it should make sense anyway...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants