-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Converting a vector to Diagonal
shouldn't work
#26178
Comments
I guess Line 15 in f4d82b2
should be restricted w.r.t the dimension of the array? Something like diff --git a/base/abstractarray.jl b/base/abstractarray.jl
index ff81756..1077add 100644
--- a/base/abstractarray.jl
+++ b/base/abstractarray.jl
@@ -12,7 +12,7 @@ Supertype for `N`-dimensional arrays (or array-like types) with elements of type
AbstractArray
convert(::Type{T}, a::T) where {T<:AbstractArray} = a
-convert(::Type{T}, a::AbstractArray) where {T<:AbstractArray} = T(a)
+convert(::Type{T}, a::AbstractArray{<:Any,N}) where {N,T<:AbstractArray{<:Any,N}} = T(a)
if nameof(@__MODULE__) === :Base # avoid method overwrite
# catch undefined constructors before the deprecation kicks in ? |
I think that line should probably be removed completely, by the same logic that it was removed for general types. |
This is a problem. We've been slowly moving to a world that supports |
Some discussion in #24595 :). |
I was involved in that discussion and I don't think there's another example in Base as egregiously confusing as One solution (which I used in BandedMatrices.jl) is to add an underscore This could be combined with an exported (and un-deprecated) |
We should narrow the |
And we shouldn't require 1-argument constructors for |
This new behaviour seems wrong:
I think the old behaviour of only supporting
Diagonal(rand(5))
was correct.The text was updated successfully, but these errors were encountered: