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

Fix ambiguity problems in sum_structs #58

Merged
merged 1 commit into from
May 21, 2024
Merged

Fix ambiguity problems in sum_structs #58

merged 1 commit into from
May 21, 2024

Conversation

Tortar
Copy link
Member

@Tortar Tortar commented May 20, 2024

So that this

using StaticArrays
using MixedStructTypes

const Point3 = SVector{3}
const Vector3 = SVector{3}

abstract type AbstractShape{T<:AbstractFloat} end

@sum_structs Shape{T<:AbstractFloat, SL, SR} <: AbstractShape{T} begin
	struct Box{T<:AbstractFloat}
	    fDimensions::Vector3{T}
	end
	struct Tube{T<:AbstractFloat}
	    rmin::T
	    rmax::T
	    z::T
	end
	struct Cone{T<:AbstractFloat}
	    r::T
	    z::T
	end
	struct BooleanUnion{T<:AbstractFloat, SL<:AbstractShape{T}, SR<:AbstractShape{T}}
	    left::SL 
	    right::SR
	end
end

box1 = Box{Float64}((1,2,3))

would work. Now we have:

ERROR: MethodError: Box{Float64}(::var"##Box#225"{Float64}) is ambiguous.

Candidates:
  Box{T}(fDimensions) where T<:AbstractFloat
    @ Main ~/.julia/dev/MixedStructTypes/src/SumStructs.jl:222
  Box{T}(ht::var"##Box#225"{T}) where T
    @ Main ~/.julia/dev/SumTypes/src/sum_type.jl:179

Possible fix, define
  Box{T}(::var"##Box#225"{T}) where T<:AbstractFloat

Stacktrace:
 [1] Box{Float64}(fDimensions::Tuple{Int64, Int64, Int64})
   @ Main ~/.julia/dev/MixedStructTypes/src/SumStructs.jl:224
 [2] top-level scope
   @ REPL[7]:1

...after MasonProtter/SumTypes.jl#78

@Tortar Tortar merged commit 3badfd0 into main May 21, 2024
0 of 13 checks passed
@Tortar Tortar deleted the Tortar-patch-1 branch May 21, 2024 11:54
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

Successfully merging this pull request may close these issues.

1 participant