Fix parsing ns :require vectors with #_ comments#416
Conversation
5dfa2fe to
779aea3
Compare
| (str "[" ignore-str "thing.core :as t]") | ||
| (str ignore-str " [" ignore-str "thing.core :as t]")] | ||
| :let [ns-str (str "(ns example (:require " ns-vec-str "))")]] | ||
| require-str ["<>[<>thing.core :as <>t :refer <>[<>my-defn]]" |
There was a problem hiding this comment.
There would have been over 5000 variations getting tested here if we did just put the metadata or uneval #_ comment form in each individual location it could go separately so instead I'm just putting it in every possible slot at once. <> is a placeholder for places it can go here and then we str/replace below
| "(t/defn foo [x]" | ||
| "(+ x 1))" | ||
| "" | ||
| "(my-defn foo [x]" |
There was a problem hiding this comment.
Updated to also test :refer handling at the same time
|
|
||
| #?(:clj | ||
| (defn- refer-zloc->refer-mapping [refer-zloc] | ||
| (let [refer-vec (some-> refer-zloc z/right z/sexpr) |
There was a problem hiding this comment.
refer-vec was incorrect since x in :refer x can be either a list or a vector
9a33f06 to
5f88abc
Compare
| "<>[<>thing <>[<>core :as <>t :refer <>[<>my-defn]]]"] | ||
| :let [ns-str (str "(ns my-namespace (:require " require-str "))")] | ||
| ns-str [ns-str | ||
| (-> ns-str |
There was a problem hiding this comment.
Try with both vectors for everything and lists for everything since either is allowed I guess, but change everything at once so we don't end up with too much of a combinatorial explosion
| ns-str [(str/replace ns-str #"<>" ignore-str) | ||
| (str/replace ns-str #"<>" (str ignore-str ignore-str))]] |
There was a problem hiding this comment.
I found another bug where multiple metadata forms e.g. ^:private ^:dynamic or whatever were not skipped over correctly in skip-meta, so I fixed that was well; updated this test to make sure we're checking strings where we use multiple uneval #_... comment forms or ^... metadata forms in a row
|
Thanks for the patch. I reviewed the code and everything looks fine, so I'll go ahead and merge. |
Fixes #415
Metadata
^...or uneval#_comment forms in various places in a form withinns:requireweren't handled correctly (before the RHS symbol of:as, before the:refersvector, before symbols within:refers, etc.), so I fixed everything and made the tests must more comprehensive; I also realized that technically:refer (x)(list instead of vector) is legal so I updated this to handle that situation as well.