Skip to content

type inference failure with getindex #44059

@cossio

Description

@cossio
sz1 = (3,2)
sz2 = (5,5)
sz3 = (3,2)
sz4 = (2,)
A = randn(sz1..., sz2..., sz3..., sz4...);
i1 = rand(CartesianIndices(sz1))
i2 = rand(CartesianIndices(sz2))
i3 = rand(CartesianIndices(sz3))
i4 = rand(CartesianIndices(sz4))
using Test
@inferred A[i1,i2,i3,i4] # fails

In this case it seems type inference is just giving up.
In fact, Base.to_indices(A, (j, k, b)) is just calling Base.to_indices(A, (), (j, k, b)).

But Base.to_indices(A, (j, k, b)) does not infer, while Base.to_indices(A, (), (j, k, b)) infers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions