Skip to content

Commit

Permalink
fix namedtuple test case
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored and vtjnash committed May 20, 2023
1 parent a9e317b commit 48955b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,11 @@ end

## from general iterable to any array

function copyto! end

# This is `Experimental.@max_methods 1 function copyto! end`, which is not
# defined at this point in bootstrap.
typeof(function copyto! end).name.max_methods = UInt8(1)
typeof(copyto!).name.max_methods = UInt8(1)

function copyto!(dest::AbstractArray, src)
destiter = eachindex(dest)
Expand Down
13 changes: 8 additions & 5 deletions base/namedtuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ julia> merge((a=1, b=2), (b=3, c=(d=1,)), (c=(d=2,),))
(a = 1, b = 3, c = (d = 2,))
```
"""
function merge(a::NamedTuple{an}, b::NamedTuple{bn}) where {an, bn}
merge(a::NamedTuple, b::NamedTuple) = _merge_nt(a, b)::NamedTuple

function _merge_nt end
typeof(_merge_nt).name.max_methods = UInt8(4)
function _merge_nt(a::NamedTuple{an}, b::NamedTuple{bn}) where {an, bn}
if @generated
names = merge_names(an, bn)
types = merge_types(names, a, b)
Expand All @@ -334,10 +338,9 @@ function merge(a::NamedTuple{an}, b::NamedTuple{bn}) where {an, bn}
merge_fallback(a, b, an, bn)
end
end

merge(a::NamedTuple, b::NamedTuple{()}) = a
merge(a::NamedTuple{()}, b::NamedTuple{()}) = a
merge(a::NamedTuple{()}, b::NamedTuple) = b
_merge_nt(a::NamedTuple, b::NamedTuple{()}) = a
_merge_nt(a::NamedTuple{()}, b::NamedTuple{()}) = a
_merge_nt(a::NamedTuple{()}, b::NamedTuple) = b

merge(a::NamedTuple, b::Iterators.Pairs{<:Any,<:Any,<:Any,<:NamedTuple}) = merge(a, getfield(b, :data))

Expand Down
3 changes: 2 additions & 1 deletion base/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ end
# @ tuple.jl:200
# [4] eltype(t::Type{<:Tuple})
# @ tuple.jl:209
typeof(function eltype end).name.max_methods = UInt8(4)
function eltype end
typeof(eltype).name.max_methods = UInt8(4)

# version of tail that doesn't throw on empty tuples (used in array indexing)
safe_tail(t::Tuple) = tail(t)
Expand Down

0 comments on commit 48955b4

Please sign in to comment.