Clojure-Intro-Course / babel

MIT License
2 stars 0 forks source link

[Le #118] Handle an optional attr-map and other multi-clause cases in defn #39

Open stanislowskij opened 2 months ago

stanislowskij commented 2 months ago

⚠️ Imported from legacy repository. This issue is a duplicate of https://github.com/Clojure-Intro-Course/babel-legacy/issues/118.

defn has an optional attribute map before and after clauses:

(defn name doc-string? attr-map? [params*] prepost-map? body)
(defn name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?)

https://clojuredocs.org/clojure.core/defn This affects figuring out which clause the error is in and also leads to unhandled cases:

babel.middleware=> (defn a {:a 7} () {:b 8})
Placeholder message for defn
In Clojure interactive session on line 1 at position 1.
Call sequence:
[Clojure interactive session (repl)]

We need to separate out determining the clause, so this would require some refactoring.

stanislowskij commented 2 months ago

Reporting clause in defn needs to be fixed for other cases as well.