clr

madeinquant 2025-11-28T13:04:52.040609Z

Title: Threading macro with update and when produces incorrect results Environment: - ClojureCLR version: 1.12.2 - .NET version: 10 - OS: MacOS 26.1 Description: The pattern (-> map (update :key #(when % (fn %)))) fails in ClojureCLR but works correctly in Clojure JVM. When chaining multiple updates in a threading macro where the anonymous function contains when, the result is incorrect or causes runtime errors. Expected Behavior: Should work identically to Clojure JVM - update with a function that returns nil should associate nil to the key. Actual Behavior: [Crashes/Wrong values/500 errors in web handlers] Workaround: Use explicit conditionals instead: `clojure (let [value (when (:key map) (fn (:key map)))] (if value (assoc map :key value) map))

dmiller 2025-12-02T04:22:13.478509Z

I think I need some more detail to get to a fail. I was thinking from your description that one or more of these might fail:

(def p1 {:name "James" :age 26})
(def p2 {:name "Fred" :age nil})
(def p3 {:name "Fred"})

(-> p1 (update :age #(when % (inc %))))   ; => {:name "James", :age 27}
(-> p2 (update :age #(when % (inc %))))   ; => {:name "Fred", :age nil}
(-> p3 (update :age #(when % (inc %))))   ; => {:name "Fred", :age nil}
They do not fail. (I tested under CLojureCLR version 1.12.2 and 1.12.3-alpha4). I thought the p2 and p3 cases would match with 'a function that returns nil should associate nil with the key. Could you provide a more specific example that illustrates the problem?

madeinquant 2025-12-02T05:59:35.451159Z

Thanks for your help. I’ll get back to you shortly with a more specific example that illustrates the problem.

seancorfield 2025-11-28T15:29:27.811469Z

@madeinquant FYI ClojureCLR issues can be reported at http://ask.clojure.org (which is the standard way to report all issues against all projects under the clojure GitHub organization).

madeinquant 2025-11-29T12:24:09.400639Z

Thank you