JuliaGeometry / JuliaGeometry/GeometryBasics.jl

Ambiguous NgonFace constructors

Open
#151 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
215
Forks
64
Avg merge
3d 18h
Merged PRs (30d)
2

Description

Constructing a NgonFace from an SVector fails because of ambiguity: StaticArrays defines some conversion constructors, which interfere with the NgonFace constructors because NgonFace <: StaticVector

MWE

using GeometryBasic, StaticArrays
t = TriangleFace(SA[0.4, 0.2, 0.55])

results in

ERROR: MethodError: (TriangleFace{T} where T)(::SVector{3, Float64}) is ambiguous. Candidates:
  (::Type{SV})(x::StaticVector{N, T} where {N, T}) where SV<:NgonFace in GeometryBasics at /home/$USER/.julia/packages/GeometryBasics/WMp6v/src/fixed_arrays.jl:74
  (::Type{SA})(a::StaticArray) where SA<:StaticArray in StaticArrays at /home/$USER/.julia/packages/StaticArrays/vxjOO/src/convert.jl:5
  (NgonFace{S, T} where T)(x::AbstractVector{T}) where {S, T} in GeometryBasics at /home/$USER/.julia/packages/GeometryBasics/WMp6v/src/fixed_arrays.jl:34
  (::Type{SA})(a::AbstractArray) where SA<:StaticArray in StaticArrays at /home/$USER/.julia/packages/StaticArrays/vxjOO/src/convert.jl:7
  (NgonFace{S, T} where T)(x::T) where {S, T} in GeometryBasics at /home/$USER/.julia/packages/GeometryBasics/WMp6v/src/fixed_arrays.jl:48
Possible fix, define
  (NgonFace{S, T} where T)(::StaticVector{N, T} where N) where {S, T}
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

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

Reproduce the Julia MWE with GeometryBasics and StaticArrays, then inspect the NgonFace constructors in src/fixed_arrays.jl around lines 34, 48, and 74. The work is done when constructing TriangleFace from the shown SVector succeeds without an ambiguity error.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.