This doesn’t seem to be inferred
julia> a = rand(1,1);
julia> @code_warntype (a -> eachslice(a, dims=1))(a)
MethodInstance for (::var"#13#14")(::Matrix{Float64})
from (::var"#13#14")(a)
@ Main REPL[23]:1
Arguments
#self#::Core.Const(var"#13#14"())
a::Matrix{Float64}
Body::Slices{Matrix{Float64}, _A, Tuple{Base.OneTo{Int64}}, _B, 1} where {_A, _B}
1 ─ %1 = (:dims,)::Core.Const((:dims,))
│ %2 = Core.apply_type(Core.NamedTuple, %1)::Core.Const(NamedTuple{(:dims,)})
│ %3 = Core.tuple(1)::Core.Const((1,))
│ %4 = (%2)(%3)::Core.Const((dims = 1,))
│ %5 = Core.kwfunc(Main.eachslice)::Core.Const(Base.var"#eachslice##kw"())
│ %6 = (%5)(%4, Main.eachslice, a)::Slices{Matrix{Float64}, _A, Tuple{Base.OneTo{Int64}}, _B, 1} where {_A, _B}
└── return %6
whereas this internal function is
julia> @code_warntype (a -> Base._eachslice(a, 1, true))(a)
MethodInstance for (::var"#15#16")(::Matrix{Float64})
from (::var"#15#16")(a)
@ Main REPL[24]:1
Arguments
#self#::Core.Const(var"#15#16"())
a::Matrix{Float64}
Body::RowSlices{Matrix{Float64}, Tuple{Base.OneTo{Int64}}, SubArray{Float64, 1, Matrix{Float64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}
1 ─ %1 = Base._eachslice::Core.Const(Base._eachslice)
│ %2 = (%1)(a, 1, true)::Core.PartialStruct(RowSlices{Matrix{Float64}, Tuple{Base.OneTo{Int64}}, SubArray{Float64, 1, Matrix{Float64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}, Any[Matrix{Float64}, Core.Const((1, Colon())), Tuple{Base.OneTo{Int64}}])
└── return %2
Since the former calls the latter, shouldn’t constant-propagation of dims
allow this to be inferred?