-
-
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
Unusal handling of Integer typed empty arrays #17811
Comments
Ref: #17717 |
nailed the issue, thanks! i'm curious what Union{} is though, does it simply mean "no possible type" rendering the array unusable? |
Just to point out, this works if you have it in a function. It is a global variable / type inference issue; julia> function f()
I = Integer[]
I = abs(I)
push!(I,1)
end
f (generic function with 1 method)
julia> f()
1-element Array{Any,1}:
1
|
@KristofferC, just tried it in 0.5 master and it still doesn't work in a function. Note also that you get the same @JeffBezanson and @pabloferz, I thought from #17172 and #17389 that we were using type inference for the empty-array case. Why is inference here returning |
You are right @stevengj , I must have tried in the wrong window. |
@stevengj Type inference is being used when the array type is concrete and/or the function is type stable for the input types. For the empty non-inferable case it returns |
@pabloferz and @JeffBezanson, I thought the conclusion of our many many discussions of this topic was:
|
@stevengj I'll try to update to this behavior and see what happens. However, the problem with mutation is more general. Unless we return an |
Won't type inference always produce a type that is at least as broad as the actual types that would be produced in the non-empty case? ( |
This tests that the result type of an empty comprehension is big enough to hold the possible results.
This tests that the result type of an empty comprehension is big enough to hold the possible results.
This tests that the result type of an empty comprehension is big enough to hold the possible results. (cherry picked from commit 93c6061)
In Julia 0.4.5, I could perform the following operations with no trouble.
An identical sequence in Julia 0.5 gives a stackoverflow error.
i realize this is a little esoteric, but what's going on? Everything's fine with Int64's
The text was updated successfully, but these errors were encountered: