From 222f61adc1686e49cec1a1f8b64b970268f9bbda Mon Sep 17 00:00:00 2001 From: Andy Dienes Date: Tue, 7 Oct 2025 16:10:35 -0400 Subject: [PATCH 1/3] deprecate `merge(::Callable ..)` in favor of `mergewith` --- base/deprecated.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/base/deprecated.jl b/base/deprecated.jl index 0ee6b6b790837..93e2b185d1a84 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -565,3 +565,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 From fabe509b54b3b2013b4efb68f705c4537c52a9a6 Mon Sep 17 00:00:00 2001 From: Andy Dienes Date: Wed, 8 Oct 2025 08:57:36 -0400 Subject: [PATCH 2/3] fix tests --- Compiler/test/inference.jl | 10 +++++----- test/dict.jl | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Compiler/test/inference.jl b/Compiler/test/inference.jl index c8df59a60c05e..112432f9cd347 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/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 From 60391a9ceaa1c16f2cfc291d9359f4edcc768518 Mon Sep 17 00:00:00 2001 From: Andy Dienes Date: Sun, 26 Oct 2025 17:20:06 -0400 Subject: [PATCH 3/3] add to news --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 05839f061b639..82d72142cdcd2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -123,4 +123,9 @@ External dependencies Tooling Improvements -------------------- +Deprecated or removed +--------------------- + +* The method `merge(combine::Callable, d::AbstractDict...)` is now deprecated to favor `mergewith` instead ([#59775]). +