It's a rather frequent question where somebody gets a syntax error when trying to use something like {:keys [a b ...] :or {b a}}
. The most recent instance: https://clojurians.slack.com/archives/C03S1KBA2/p1742549907988549
The error is as user-unfriendly as it gets and the behavior is also counter-intuitive if you don't happen to know the insides of destructuring and maps.
Perhaps it would make sense to alter the destructuring impl for when the default value in :or
is not a primitive. So instead of being expanded to b (get map__1 :b a)
it's expanded to b (get map__1 :b ::not-found)
with a subsequent rebinding to b (if (identical? b ::not-found) a b)
after all the other keys have already been extracted.