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.
  • Loading branch information
ranocha committed Sep 15, 2022
1 parent 9b1780d commit e758982
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) = isdefined(nt, key) ? getfield(nt, key) : default
get(f::Callable, nt::NamedTuple, key::Union{Integer, Symbol}) = isdefined(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)
reverse(nt::NamedTuple) = NamedTuple{reverse(keys(nt))}(reverse(values(nt)))

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

0 comments on commit e758982

Please sign in to comment.