taoensso / encore

Core utils library for Clojure/Script
https://www.taoensso.com/encore
Eclipse Public License 1.0
274 stars 52 forks source link

`nested-merge` now throws exception when passed no arguments #70

Closed jjttjj closed 8 months ago

jjttjj commented 8 months ago

Hi! I have some code that applies taoensso.encore/nested-merge to a variable number of arguments, occasionally zero arguments, e.g. (enc/nested-merge). In version 3.24.1 this returned nil, but when upgrading to 3.74.0 it now throws an exception:

{
 :cause "Wrong number of args (2) passed to: taoensso.encore/-merge-with"
 :via
 [{:type clojure.lang.ArityException
   :message "Wrong number of args (2) passed to: taoensso.encore/-merge-with"
   :at [clojure.lang.AFn throwArity "AFn.java" 429]}]
 :trace
 [[clojure.lang.AFn throwArity "AFn.java" 429]
  [clojure.lang.AFn invoke "AFn.java" 36]
  [clojure.core$partial$fn__5922 invoke "core.clj" 2647]
  [clojure.core.protocols$fn__8238 invokeStatic "protocols.clj" 78]
  [clojure.core.protocols$fn__8238 invoke "protocols.clj" 75]
  [clojure.core.protocols$fn__8192$G__8187__8205 invoke "protocols.clj" 13]
  [clojure.core$reduce invokeStatic "core.clj" 6904]
  [clojure.core$reduce invoke "core.clj" 6890]
  [taoensso.encore$_merge_with invokeStatic "encore.cljc" 2463]
  [taoensso.encore$_merge_with invoke "encore.cljc" 2461]
  [taoensso.encore$eval2388$nested_merge__2395 doInvoke "encore.cljc" 2519]
  [clojure.lang.RestFn invoke "RestFn.java" 400]
  ....

I believe this is similarly true with, e.g. (enc/nested-merge-with +).

Since the previous versions and the clojure core merge functions return nil in these case, and I couldn't find any mention of this being an intended change, I thought it might be a bug. But no big deal if this is intended or desired change, just wanted to bring it to your attention in case it's not.

Thanks as always for your work on your excellent Clojure libraries!

ptaoussanis commented 8 months ago

@jjttjj Hi Justin, thanks so much for pinging about this! 🙏

The change was indeed an unintended regression, and should be fixed with [com.taoensso/encore "3.74.1"] - on Clojars now.

Apologies for the trouble!

jjttjj commented 8 months ago

Thanks for the fix! Can confirm this works for me now on 3.74.1

ptaoussanis commented 8 months ago

Great, thanks for the confirmation 🙏 Cheers :-)