diff --git a/Compiler/test/inference.jl b/Compiler/test/inference.jl index 3ae787e108cf0..ccbcb06a631ba 100644 --- a/Compiler/test/inference.jl +++ b/Compiler/test/inference.jl @@ -3509,11 +3509,11 @@ end struct MixedKeyDict{T<:Tuple} #<: AbstractDict{Any,Any} dicts::T end -Base.merge(f::Function, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...) -Base.merge(f, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...) +Base.mergewith(f::Function, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...) +Base.mergewith(f, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...) function _merge(f, res, d, others...) ofsametype, remaining = _alloftype(Base.heads(d), ((),), others...) - return _merge(f, (res..., merge(f, ofsametype...)), Base.tail(d), remaining...) + return _merge(f, (res..., mergewith(f, ofsametype...)), Base.tail(d), remaining...) end _merge(f, res, ::Tuple{}, others...) = _merge(f, res, others...) _merge(f, res, d) = MixedKeyDict((res..., d...)) @@ -3537,9 +3537,9 @@ _alloftype(ofdesiredtype, accumulated) = ofdesiredtype, Base.front(accumulated) let d = MixedKeyDict((Dict(1 => 3), Dict(4. => 2))) e = MixedKeyDict((Dict(1 => 7), Dict(5. => 9))) - @test merge(+, d, e).dicts == (Dict(1 => 10), Dict(4.0 => 2, 5.0 => 9)) + @test mergewith(+, d, e).dicts == (Dict(1 => 10), Dict(4.0 => 2, 5.0 => 9)) f = MixedKeyDict((Dict(2 => 7), Dict(5. => 11))) - @test merge(+, d, e, f).dicts == (Dict(1 => 10, 2 => 7), Dict(4.0 => 2, 5.0 => 20)) + @test mergewith(+, d, e, f).dicts == (Dict(1 => 10, 2 => 7), Dict(4.0 => 2, 5.0 => 20)) end # Issue #31974 diff --git a/base/deprecated.jl b/base/deprecated.jl index 088c77b3cbabb..241888ba45471 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -566,3 +566,9 @@ end to_power_type(x) = oftype(x*x, x) # END 1.12 deprecations + +# BEGIN 1.13 deprecations + +@deprecate merge(combine::Callable, d::AbstractDict, others::AbstractDict...) mergewith(combine, d, others...) + +# end 1.13 deprecations diff --git a/test/dict.jl b/test/dict.jl index b3d69a76420ae..b2941088772f9 100644 --- a/test/dict.jl +++ b/test/dict.jl @@ -1289,8 +1289,6 @@ struct NonFunctionCallable end @test @inferred mergewith(NonFunctionCallable(), d1, d2) == Dict("A" => 1, "B" => 5, "C" => 4) @test foldl(mergewith(+), [d1, d2]; init=Dict{Union{},Union{}}()) == Dict("A" => 1, "B" => 5, "C" => 4) - # backward compatibility - @test @inferred merge(+, d1, d2) == Dict("A" => 1, "B" => 5, "C" => 4) end @testset "Dict merge!" begin