-
-
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
WIP: remove fallback eltype
that returns Any
for all types
#26852
Conversation
@@ -350,7 +350,7 @@ function precise_container_type(@nospecialize(arg), @nospecialize(typ), vtypes:: | |||
else | |||
return Any[ p for p in tti0.parameters ] | |||
end | |||
elseif tti0 <: Array | |||
elseif tti0 isa Type{<:Array{T}} where T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
aren't these supposed to be equivalent, with the subtyping test likely being more reliable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type{<:Array{T}} where T
is a strict subtype of Type{<:Array}
, since no value of T
turns Array{T}
into Array
.
base/iterators.jl
Outdated
@@ -233,10 +233,10 @@ size(v::Pairs) = size(v.itr) | |||
end | |||
@inline done(v::Pairs, state) = done(v.itr, state) | |||
|
|||
eltype(::Type{Pairs{K, V}}) where {K, V} = Pair{K, V} | |||
eltype(::Type{<:Pairs{K, V}}) where {K, V} = Pair{K, V} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to now handle the cases where !@isdefined K
or !@isdefined V
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and now I notice this can actually be deleted since it's covered by the eltype
method for AbstractDict
.
59a707b
to
9ce01d8
Compare
Triage accepts. |
9ce01d8
to
c4f1e48
Compare
Why not give a deprecation instead of a method error? |
c4f1e48
to
2b958e4
Compare
So, the real issue here seems to be that the default value of Of course, |
fix IteratorSize of AsyncGenerator add some missing `eltype` methods
2b958e4
to
879ce9d
Compare
Wouldn't it make sense to change the default to not having an eltype? That seems like a strange default to me. |
It's a nuisance; every time you define |
For a long time we've allowed
eltype
to be called on anything and returnAny
(eltype(:x)
,eltype(+)
, you name it). This feels very julia 0.1 to me and doesn't seem like a good thing.Removing this method already uncovered a couple bugs, where iterators were silently and incorrectly getting
Any
fromeltype
because the wrong method was called.The part of this I'm not sure about is the
Random
code, where the Sampler types have an eltype parameter, and calleltype
on a constructor argument to populate it. Some of the types passed here do not haveeltype
methods, and indeed the tests pass if I just replace theeltype
calls withAny
. So maybe this type parameter is unused and can just be removed. cc @rfourquetCurrently I have the fallbackeltype
give a MethodError, but it could be a deprecation warning instead.