julia
4290fa33 - inference: Fix `getfield` on `PartialStruct` of `NamedTuple` with unknown names (#65424)

Commit
1 day ago
inference: Fix `getfield` on `PartialStruct` of `NamedTuple` with unknown names (#65424) Since #61719, `abstract_eval_new` can form a `PartialStruct` for a non-concrete type such as `NamedTuple{N, Tuple{Float64, Float64}} where N`. `_getfield_tfunc` on a `PartialStruct` returned `Bottom` whenever `fieldindex` gave 0, but `fieldindex` gives 0 for every name of a `NamedTuple` whose names are a type variable, so a valid field read like `nt.a` was inferred as `Union{}` and compiled to an `unreachable` trap. The `PartialStruct` now only refines accesses to a valid field index and leaves everything else to the type-level tfunc on the widened type, which already handles `NamedTuple`s with unknown names as well as accesses to nonexistent fields. Fixes #65408
Author
Parents
Loading