Make haskey(::@Kwargs{item::Bool}, :item) constant-fold#59320
Make haskey(::@Kwargs{item::Bool}, :item) constant-fold#59320topolarity merged 2 commits intoJuliaLang:masterfrom
haskey(::@Kwargs{item::Bool}, :item) constant-fold#59320Conversation
|
Yes I think this is ok. Note We may have thought of extending Pairs to allow e.g. subsetting keys, but obviously we are not going to implement that now. I think it really is out of scope and better suited to a different view-like type. |
|
Idea to consider: we could make this "safer" by making |
76430fb to
7a38428
Compare
I tried this approach, and I think I like it better. That puts us in a better position to resolve #59292 ( |
Rather than assume the value of `.itr` for `Pairs{..., <:NamedTuple}`
this introduces `nothing` as a sentinel to iterate `.data` directly,
which is sufficient for this to const-prop.
This restricts this optimization to apply only to "fully-iterated" NamedTuple Pairs, which are the only kind generated by lowering and `Base.pairs`. Resolves JuliaLang#59292.
eff4126 to
3f20eec
Compare
Resolves #59269.
Makes #59292 somewhat worse by doubling-down on the same assumptions.We should straighten out that issue properly, but I don't see any reason not to get better inference in the mean time for the very commonWe are already relying on those assumptions in Base (as that issue demonstrates), and @JeffBezanson says that this functionality wasn't intended to be supported:@Kwargscase.edit: now also resolves #59292.