Skip to content

Commit

Permalink
improve type stability of tail/front(::NamedTuple) (#46762)
Browse files Browse the repository at this point in the history
This fixes some invalidations when loading ChainRulesCore.jl.

(cherry picked from commit e758982)
  • Loading branch information
ranocha authored and KristofferC committed Sep 16, 2022
1 parent 22d1000 commit ab67e93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/namedtuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ values(nt::NamedTuple) = Tuple(nt)
haskey(nt::NamedTuple, key::Union{Integer, Symbol}) = isdefined(nt, key)
get(nt::NamedTuple, key::Union{Integer, Symbol}, default) = haskey(nt, key) ? getfield(nt, key) : default
get(f::Callable, nt::NamedTuple, key::Union{Integer, Symbol}) = haskey(nt, key) ? getfield(nt, key) : f()
tail(t::NamedTuple{names}) where names = NamedTuple{tail(names)}(t)
front(t::NamedTuple{names}) where names = NamedTuple{front(names)}(t)
tail(t::NamedTuple{names}) where names = NamedTuple{tail(names::Tuple)}(t)
front(t::NamedTuple{names}) where names = NamedTuple{front(names::Tuple)}(t)

@pure function diff_names(an::Tuple{Vararg{Symbol}}, bn::Tuple{Vararg{Symbol}})
@nospecialize an bn
Expand Down

0 comments on commit ab67e93

Please sign in to comment.