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

Avoid piracy #1248

Open
aplavin opened this issue Mar 9, 2024 · 2 comments
Open

Avoid piracy #1248

aplavin opened this issue Mar 9, 2024 · 2 comments

Comments

@aplavin
Copy link
Member

aplavin commented Mar 9, 2024

StaticArrays does some piracy, at least in similar():

const HeterogeneousBaseShape = Union{Integer, Base.OneTo}
const HeterogeneousShape = Union{HeterogeneousBaseShape, SOneTo}
const HeterogeneousShapeTuple = Tuple{Vararg{HeterogeneousShape}}
similar(A::AbstractArray, ::Type{T}, shape::HeterogeneousShapeTuple) where {T} = similar(A, T, homogenize_shape(shape))
similar(::Type{A}, shape::HeterogeneousShapeTuple) where {A<:AbstractArray} = similar(A, homogenize_shape(shape))

Here,

HeterogeneousShapeTuple = Tuple{Vararg{Union{Integer, Base.OneTo, SOneTo} }} 

and it fits eg Tuple{}, Tuple{Int}, Tuple{Int, Int}.

It's generally a good thing to avoid piracy in foundational packages. Maybe, also related to ambiguities like JuliaArrays/StructArrays.jl#279?..

@jishnub
Copy link
Member

jishnub commented Mar 10, 2024

Strictly speaking, this isn't piracy, as the narrower method is defined in Base. It would be good to remove this, though, if possible

@mateuszbaran
Copy link
Collaborator

It would be great if we actually had non-ambiguous documentation about what is and what isn't type piracy so that we can be sure what is and what is not wrong, ref. JuliaLang/julia#51669 . Currently there seems to be no consensus nor clear communication from core Julia devs regarding this "wider union" case.

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

3 participants