-
Couldn't load subscription status.
- Fork 44
Open
Description
There are a lot of Any inferred types in this example:
struct Foo
x::StructVector{NamedTuple{(:a, :b), Tuple{Int64, Float64}}}
end
f = Foo(StructVector(a=[1,2,3], b=[0.1, 0.2, 0.3]))
function first_prod(f::Foo)
f.x.a[1] * f.x.b[1]
end
@code_typed first_prod(f)
outputs:
CodeInfo(
1 ─ %1 = Base.getfield(f, :x)::StructVector{NamedTuple{(:a, :b), Tuple{Int64, Float64}}}
│ %2 = StructArrays.getfield(%1, :components)::Union{Tuple, NamedTuple}
│ %3 = StructArrays.getfield(%2, :a)::Any
│ %4 = Base.getindex(%3, 1)::Any
│ %5 = Base.getfield(f, :x)::StructVector{NamedTuple{(:a, :b), Tuple{Int64, Float64}}}
│ %6 = StructArrays.getfield(%5, :components)::Union{Tuple, NamedTuple}
│ %7 = StructArrays.getfield(%6, :b)::Any
│ %8 = Base.getindex(%7, 1)::Any
│ %9 = (%4 * %8)::Any
└── return %9
) => AnyMetadata
Metadata
Assignees
Labels
No labels