In :or destructuring, values should not depend on other bindings
- Dominant language
- Clojure
- Stars
- 970
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
Just generally, there is no defined evaluation order for the value expressions of a destructuring `:or` wrt the other destructuring clauses.
There is an ordering assumption being made in [this test](https://github.com/funcool/cats/blob/6c31cc42c788b109d9c376c73cbf82ae22bb70bb/src/cats/labs/test.cljc#L74-L80) that I believe will no longer be true in the next Clojure 1.13.0-alpha4 due to changing implementation.
```
(defn monoid-identity-element
[{:keys [ctx gen empty eq] :or {empty (m/mempty ctx) eq =}}]
...
```
Here, the use of `ctx` in the `:or` assumes `ctx` has been bound, but that is not a guarantee, and will in fact not be the case as of the next alpha, so I would recommend modifying this code, probably pulling it into two steps.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with src/cats/labs/test.cljc, especially the monoid-identity-element definition and the linked lines 74-80. Review how the destructuring :or expressions use ctx, then adjust the code so those values do not depend on binding order. The linked test should continue to cover the behavior without relying on that ordering assumption.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100