Open
Description
Hi,
I'm trying to get a view of a part of a ComponentMatrix
, but it seems this sometimes is not type-stable. In particular, if one of the indices is a non-constant integer I get a type-unstable view
:
using ComponentArrays
small_comp_array = ComponentArray(a=[0.1, 0.2], b=0.3)
comp_matrix = ComponentMatrix(randn(3, 5), getaxes(small_comp_array)[1], FlatAxis())
get_a1(x) = view(x, Val(:a), 1)
get_a(x, i) = view(x, Val(:a), i)
@code_warntype get_a1(comp_matrix) #Type-stable
@code_warntype get_a(comp_matrix, 1) #Not type-stable
I'm using Julia 1.11.5.
Is this a special case of #9? I'm surprised that the Val around the symbol doesn't fix the const propagation.