Details
Assignee
UnassignedUnassignedReporter
Alex MillerAlex MillerLabels
Approval
TriagedPriority
MajorAffects versions
Details
Details
Assignee
Unassigned
UnassignedReporter
Alex Miller
Alex MillerLabels
Approval
Triaged
Priority

Affects versions
Created April 10, 2023 at 3:44 PM
Updated April 10, 2023 at 3:44 PM
Per https://ask.clojure.org/index.php/12840/inserting-at-top-of-zipper-doesnt-throw-after-change
Inserting at the top throws:
(require '[clojure.zip :as z]) (-> (z/vector-zip []) (z/insert-right :foo) z/root) ;; Execution error: Insert at top
However, making any edit first will cause the insert to instead be silently ignored rather than throw:
(-> (z/vector-zip []) (z/replace []) (z/insert-right :foo) z/root) ;; []
Cause:
z/replace
sets:changed? true
in the path slot of the loc andz/insert-left
andz/insert-right
(andz/remove
) check whether the path is nil (which it now isn't).Approach: Probably the simplest approach would be to have a more refined check in
insert-left
andinsert-right
. Another option might be to changereplace
somehow.