-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
map
with an invalid function body returns Union{}[]
#47415
Comments
map
with an invalid contents returns Union{}[]
map
with an invalid function body returns Union{}[]
This is the smallest type, while Any is the largest. I think that ensures it can be composed with anything, like so: julia> map(_ -> error(), [])
Union{}[]
julia> collect(Iterators.flatten(()))
Union{}[]
julia> vcat(ans, [true]) # 1st arg never widens the type
1-element Vector{Bool}:
1
julia> vcat(Nothing[], [true])
1-element Vector{Union{Nothing, Bool}}:
true |
Closing as not planned, since I think this is per-design. But feel free to make an argument why it is not right however! |
Thanks! I don't know if I have one, other than it being unusual. For context, the reason I noticed was that in Pluto (via Colors), when it tried to show the object, it encountered a type ambiguity which to me seemed nonintuitive:
Should methods need to guard against |
In 1.8.2:
This inner method call is invalid and will never work for non-empty input, but for consistency, shouldn't the return type for the empty case either be
Nothing[]
orAny[]
?The text was updated successfully, but these errors were encountered: