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

0 votes
in Clojure by

(assoc-in {} [] 1) ;=> {nil 1}

This should probably throw an exception.

CLJ-373 has a patch ((link: http://dev.clojure.org/jira/secure/attachment/12897/CLJ-373-nested-ops.patch text: CLJ-373-nested-ops.patch)) which fixes this (by throwing an exception on empty key paths), the related broken behavior of update-in, and documents empty key path behavior in get-in et al. I can pull just the assoc-in stuff out of that into a separate patch, but I am really hoping that all the issues in the patch addresses are resolved at once, I.e.:

(get-in {} [] :notfound) ;=> {} ; ok (get-in {nil 1} [] :notfound) ;=> {nil 1} ; ok (assoc-in {} [] 1) ;=> {nil 1} ; wat? (assoc-in {nil 0} [] 1) ;=> {nil 1} ; wat? (update-in {} [] identity) ;=> {nil nil} ; wat? (update-in {nil 0} [] inc) ;=> {nil 1} ; wat?

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1520 (reported by favila)
...