julia> map(spair) do ci
(&)(sbool[ci]...)
end
4-element SArray{Tuple{4},Any,1,4}:
true
false
false
false
To help see what’s going on, I wanted to use @code_warntype, which means wrapping it in a function. Suddenly, it’s type stable:
julia> foo(spair, sbool) = map(spair) do ci
(&)(sbool[ci]...)
end
foo (generic function with 1 method)
julia> @code_warntype foo(spair, sbool)
Body::SArray{Tuple{4},Bool,1,4}
1 1 ─ %1 = new(getfield(Main, Symbol("##37#38")){SArray{Tuple{4},Bool,1,4}}, %%sbool)::getfield(Main, Symbol("##37#38")){SArray{Tuple{4},Bool,1,4}} │
│ %2 = :(StaticArrays.Tuple)::Type{Tuple} │╻╷╷╷ map
│ Core.apply_type(%2, 4) ││┃│││ _map
│ %4 = Base.getfield(%%spair, :data)::NTuple{4,Array{Int64,1}} │││╻ macro expansion
│ %5 = Base.getfield(%4, 1, false)::Array{Int64,1} ││││╻ getindex
│ %6 = invoke %1(%5::Array{Int64,1})::Bool ││││
│ %7 = Base.getfield(%%spair, :data)::NTuple{4,Array{Int64,1}} │││││╻ getproperty
│ %8 = Base.getfield(%7, 2, false)::Array{Int64,1} │││││╻ getindex
│ %9 = invoke %1(%8::Array{Int64,1})::Bool ││││
│ %10 = Base.getfield(%%spair, :data)::NTuple{4,Array{Int64,1}} │││││╻ getproperty
│ %11 = Base.getfield(%10, 3, false)::Array{Int64,1} │││││╻ getindex
│ %12 = invoke %1(%11::Array{Int64,1})::Bool ││││
│ %13 = Base.getfield(%%spair, :data)::NTuple{4,Array{Int64,1}} │││││╻ getproperty
│ %14 = Base.getfield(%13, 4, false)::Array{Int64,1} │││││╻ getindex
│ %15 = invoke %1(%14::Array{Int64,1})::Bool ││││
│ %16 = StaticArrays.tuple(%6, %9, %12, %15)::NTuple{4,Bool} ││││
│ %17 = new(SArray{Tuple{4},Bool,1,4}, %16)::SArray{Tuple{4},Bool,1,4} ││││╻ Type
└── goto 3 ││││
2 ─ unreachable ││││
3 ─ goto 4 ││
4 ─ return %17 │
julia> foo(spair, sbool)
4-element SArray{Tuple{4},Bool,1,4}:
true
false
false
false