If I understand correctly, inlining can never help with type stability, because it’s done after the type inference step (https://github.com/JuliaLang/julia/issues/17880). It’s a significant issue for my code, too… I don’t think there’s a solution to your problem, except to use Val{i} for the index. In general you can use a macro to avoid the problem, but it doesn’t work because you need dispatch.
2 Likes