-
-
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
Make return type of map inferrable with heterogeneous arrays #42046
Conversation
Inference is not able to detect the element type automatically, but we can do it manually since we know promote_typejoin is used for widening. This is similar to the approach used for `broadcast` at #30485.
base/array.jl
Outdated
ElType = promote_typejoin_union(et) | ||
ElType′ = ElType <: Type ? Type : ElType |
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.
Seems like this should be part of the et
computation at the top of the function (so that the total function here is more type-stable), no?
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.
Actually I did the same for broadcast
(see here) so that would make sense, even if that changes the return type in corner cases. I've just pushed a commit to do this.
I'm told FreeBSD failure is unrelated. Merging. |
Backporting since it is a bit tangled up with #42172 |
Hi, I just noticed that the newly introduced type assertion in map(enumerate(1:4)) do (i, _)
a = (x=i, y=(i==1 ? 1 : "a"))
(a, 3)
end Throws the following error
I just upgraded to 1.7.0-rc3 from rc1 this morning and immediately ran into this. Looks like the computed type annotation is more precise but is somehow not compatible with the actual returned collection type. |
…ng#42046) Inference is not able to detect the element type automatically, but we can do it manually since we know promote_typejoin is used for widening. This is similar to the approach used for `broadcast` at JuliaLang#30485.
…ng#42046) Inference is not able to detect the element type automatically, but we can do it manually since we know promote_typejoin is used for widening. This is similar to the approach used for `broadcast` at JuliaLang#30485.
Inference is not able to detect the element type automatically,
but we can do it manually since we know promote_typejoin is used for widening.
This is similar to the approach used for
broadcast
at #30485.