You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This improves a common scenario, where someone wants to `push!` a
poorly-typed object onto a well-typed Vector.
For example:
```julia
const NT = @NamedTuple{x::Int,y::Any}
foo(v::Vector{NT}, x::Int, @nospecialize(y)) = push!(v, (; x, y))
```
The `(; x, y)` is slightly poorly-typed here. It could have any type for
its `.y` field before it is converted inside the `push!` to a NamedTuple
with `y::Any`
Without this PR, the dispatch for this `push!` cannot be inferred:
```julia
julia> code_typed(foo, (Vector{NT}, Int, Any))[1]
CodeInfo(
1 ─ ...
│ %4 = %new(%3, x, y)::NamedTuple{(:x, :y), <:Tuple{Int64, Any}}
│ %5 = Main.push!(v, %4)::Vector{@NamedTuple{x::Int64, y}}
└── return %5
) => Vector{@NamedTuple{x::Int64, y}}
```
With this PR, the above dynamic call is fully statically resolved and
inlined (and therefore `--trim` compatible)
0 commit comments