-
-
Notifications
You must be signed in to change notification settings - Fork 71
Closed
Labels
Description
Describe the bug 🐞
Accessing a recursive array with [1, end] is type-unstable. Was type stable on v3.41 and earlier, broken on 3.42 and later. Related to @JoshuaLampert 's recent work, it seems.
Expected behavior
Type stability for array accesses.
Minimal Reproducible Example 👇
vecvec = VectorOfArray([fill(2.0, 2) for i in 1:10])
access_end(vec) = vec[1, end]
@code_warntype access_end(vecvec)yields
MethodInstance for access_end(::VectorOfArray{Float64, 2, Vector{Vector{Float64}}})
from access_end(vec) @ Main REPL[4]:1
Arguments
#self#::Core.Const(Main.access_end)
vec::VectorOfArray{Float64, 2, Vector{Vector{Float64}}}
Body::Any
1 ─ %1 = Base.lastindex(vec, 2)::Core.PartialStruct(RecursiveArrayTools.RaggedEnd, Any[Core.Const(0), Int64])
│ %2 = Base.getindex(vec, 1, %1)::Any
└── return %2
Error & Stacktrace
Digging around with Cthulhu, I see:
that is, starting at https://github.com/SciML/RecursiveArrayTools.jl/blob/6519ecf4fbf69a6134051d1fa11ad5685dd93c3a/src/vector_of_array.jl#L838,
`cols`, `prefix`, `resolved`, `inner_nd`, `padded` all are getting boxed somehow and killing the inference.Reactions are currently unavailable