Welcome! Please see the About page for a little more info on how this works.

0 votes
ago in ClojureCLR by

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:

 (let [value (when (:key map) (fn (:key map)))]
    (if value (assoc map :key value) map))'

Please log in or register to answer this question.

...