taoensso / timbre

Pure Clojure/Script logging library
https://www.taoensso.com/timbre
Eclipse Public License 1.0
1.44k stars 171 forks source link

Exception thrown when log arguments have same name, but different separators #368

Closed mike706574 closed 1 year ago

mike706574 commented 1 year ago

We tried to log a formatted message where two args have the same var name, except one uses kebab case and the other uses snake case (x_y versus x-y) - here's a simplified example:

(let [x_y "a"
      x-y "b"]
  (timbre/infof "%s %s" x-y x_y))

And got this exception:

Unhandled clojure.lang.Compiler$CompilerExceptionUnhandled 
  Caused by java.lang.ClassFormatError
  Duplicate field name "x_y" with signature "Ljava.lang.Object;" in class file

Definitely an easy situation to avoid by changing the names, but is this something that should work?

ptaoussanis commented 1 year ago

@mike706574 Hi Mike,

This is actually an issue with Clojure, not Timbre. Your example can be reduced to the following:

(let [x- 1
      x_ 2]
  (fn [] [x- x_])) ; => Duplicate field name "x_" with signature "J" in class file

I'm only aware of this since there was, remarkably, another report of this recently - also against Timbre.

As I mentioned on that issue, it's not obvious to me whether this is an intended Clojure limitation or a bug. I'd guess the former, but this would need to be verified.

Your options seem to be:

  1. Escalate (e.g. on the Clojure Google Group) to see if the behaviour is possibly unintentional and can be fixed upstream.
  2. Avoid the duplicate naming.

Sorry I can't suggest anything else. Best of luck!

mike706574 commented 1 year ago

Interesting! Yeah, we're just avoiding the duplicate naming, and this is temporary code anyways until casing issues are resolved. I don't know why any sane person would use names like this. Thanks!