[spec] Add extra map argument to clojure.core/assert and clojure.spec/assert (like with ex-info)

Description

It's a common requirement to provide extra info about the context of the assertion. For instance one might want to include values of local or dynamic bindings into the assert report, or use `clojure.spec/assert` to leverage structured errors with specs outside of testing environments.

With clojure.core/assert one can splice extra data into formated message but with clojure.spec/assert there is no such feature. The message argument to clojure's assert was added in CLJ-774, and it was acknowledged there that the mechanism is not ideal. One notable benefit of passing reports as data is that editors can handle those gracefully in case of large data.

This proposal is related to but has a broader scope. With an extra map one can pass any value (not just locals), and there is no danger of inadvertently flooding the REPL with large locals.

Environment

None

Assignee

Unassigned

Reporter

Vitalie Spinu

Labels

Approval

Triaged

Patch

None

Affects versions

Priority

Major
Configure