-
Notifications
You must be signed in to change notification settings - Fork 40
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
Type piracy breaks Base.similar on JuMP containers #369
Comments
Not defending type piracy here, but ambiguity errors like this can arise without any piracy at all. And this happens regularly! |
I would argue that StaticArrays is doing some fishy stuff with the type unions there. I don't want to go into the rabbit hole of getting the exact type piracy definition as mentioned in JuliaArrays/StaticArrays.jl#1248 where you could say that the wider Union does not affect dispatch in Base. It seems reasonable to me that neither of below should be defined in package A: function packageB.func(data::packageC.sometype) end
function packageB.func(data::Union{packageA.sometype,packageC.sometype}) end
function packageB.func(data::packageD.sometype{T}) where {T<:packageC.sometype} end |
Yes, as I said I'm not defending piracy here :) |
Type-piracy aside, the method defined in function Base.similar(
A::DenseAxisArray{T,N,Ax},
::Type{S},
axes::Ax,
-) where {T,N,Ax<:Tuple{<:AbstractVector},S}
+) where {T,N,Ax<:Tuple{AbstractUnitRange{<:Integer}},S}
return construct_undef_array(S, axes)
end These are the only types valid as axes of an |
I think the point of the DenseAxisArray in JuMP is that you can have more flexible indices than just the AbstractUnitRange (see their documentation). At that point the DenseAxisArray becomes a regular Array I guess? |
Hi, I've seen that type piracy has already been discussed in the issues here (#87). This issue is to highlight a specific case which is bugging me. I will refrain from philosophizing on #87 here.
The JuMP implementation for the
Base.similar(a::JuMP.Containers.DenseAxisArray, ::Type, axes)
seems pretty reasonable to me (pasted below) but breaks due to the type piracy in this package.The text was updated successfully, but these errors were encountered: