Skip to content
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

reduce type inference on 1.6 #40277

Closed
mzgubic opened this issue Mar 31, 2021 · 4 comments · Fixed by #40294
Closed

reduce type inference on 1.6 #40277

mzgubic opened this issue Mar 31, 2021 · 4 comments · Fixed by #40294
Labels
compiler:inference Type inference regression Regression in behavior compared to a previous version

Comments

@mzgubic
Copy link

mzgubic commented Mar 31, 2021

On julia 1.5

julia> using Test

julia> x_vecs = ([5, ], [1.0, 2.0, 3.0]);

julia> @inferred reduce(vcat, x_vecs)
4-element Array{Float64,1}:
 5.0
 1.0
 2.0
 3.0

On julia 1.6

julia> @inferred reduce(vcat, x_vecs)
ERROR: return type Vector{Float64} does not match inferred return type AbstractVector{T} where T
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] top-level scope
   @ REPL[66]:1

julia> @inferred vcat(x_vecs...)
4-element Vector{Float64}:
 5.0
 1.0
 2.0
 3.0
@mzgubic mzgubic changed the title reduce type inference on 1.6 reduce type inference on 1.6 Mar 31, 2021
@mzgubic
Copy link
Author

mzgubic commented Mar 31, 2021

Interestingly,

julia> @inferred reduce(vcat, ([10.0], Bool[], [30.0]))
2-element Vector{Float64}:
 10.0
 30.0

julia> @inferred reduce(vcat, ([10.0], [20.0], Bool[]))
ERROR: return type Vector{Float64} does not match inferred return type AbstractVector{T} where T
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] top-level scope
   @ REPL[114]:1

@KristofferC
Copy link
Member

I'll try bisect it.

@KristofferC KristofferC added compiler:inference Type inference regression Regression in behavior compared to a previous version labels Mar 31, 2021
@KristofferC
Copy link
Member

Bisection blames b4f2c66, cc @dlfivefifty

@dlfivefifty
Copy link
Contributor

Found a fix, will make a PR:

julia> x_vecs = ([5, ], [1.0, 2.0, 3.0]);

julia> @inferred reduce(vcat, x_vecs);
ERROR: return type Vector{Float64} does not match inferred return type AbstractVector{T} where T
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] top-level scope
   @ REPL[2]:1

julia> Base._typed_vcat(::Type{T}, V::Base.AbstractVecOrTuple{AbstractVector}) where T = Base._typed_vcat!(Base._typed_vcat_similar(V, T, sum(map(length,V))), V)

julia> @inferred reduce(vcat, x_vecs);

julia> 

dlfivefifty added a commit to dlfivefifty/julia that referenced this issue Apr 1, 2021
KristofferC pushed a commit that referenced this issue Apr 4, 2021
KristofferC pushed a commit that referenced this issue Apr 4, 2021
KristofferC pushed a commit that referenced this issue Apr 4, 2021
staticfloat pushed a commit that referenced this issue Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants