You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a fresh julia session (v1.4.1), the following type inference test fails
x = [ones(3) for _ in1:2]
s1(x) = x ./sum(x)
testf(x) =s1.(x)
@inferredtestf(x)
if
s1(x) = x ./sum(x)
testf(x) =s1.(x)
are redefined, the test passes.
Output of REPL session below
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.1 (2020-04-14)
_/ |\__'_|_|_|\__'_| |
|__/ |
julia> x = [ones(3) for _ in 1:2]
2-element Array{Array{Float64,1},1}:
[1.0, 1.0, 1.0]
[1.0, 1.0, 1.0]
julia> s1(x) = x ./ sum(x)
s1 (generic function with 1 method)
julia> testf(x) = s1.(x)
testf (generic function with 1 method)
julia> @inferred testf(x)
ERROR: return type Array{Array{Float64,1},1} does not match inferred return type Any
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] top-level scope at none:0
julia> s1(x) = x ./ sum(x)
s1 (generic function with 1 method)
julia> testf(x) = s1.(x)
testf (generic function with 1 method)
julia> @inferred testf(x)
2-element Array{Array{Float64,1},1}:
[0.3333333333333333, 0.3333333333333333, 0.3333333333333333]
[0.3333333333333333, 0.3333333333333333, 0.3333333333333333]
I think the problem lies in the broadcast machinery, if I replace
testf(x) =map(s1,x)
the problem goes away.
Cthulhu.jl points at Base.Broadcast.copy(%7::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Tuple{Base.OneTo{Int64}},typeof(s1),Tuple{Array{Array{Float64,1},1}}})::Any being the problem:
In a fresh julia session (v1.4.1), the following type inference test fails
if
are redefined, the test passes.
Output of REPL session below
I think the problem lies in the broadcast machinery, if I replace
the problem goes away.
Cthulhu.jl points at
Base.Broadcast.copy(%7::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Tuple{Base.OneTo{Int64}},typeof(s1),Tuple{Array{Array{Float64,1},1}}})::Any
being the problem:The text was updated successfully, but these errors were encountered: