diff --git a/core/data/core.joke b/core/data/core.joke index 9815b16e8..42157fa56 100644 --- a/core/data/core.joke +++ b/core/data/core.joke @@ -2469,7 +2469,11 @@ ;redefine let and loop with destructuring (defn ^:private destructure [bindings] - (let [bents (partition 2 bindings) + (let [mark-as (fn [s] + (if (and *linter-mode* (false? (:unused-as (:rules *linter-config*)))) + (vary-meta s assoc :skip-unused true) + s)) + bents (partition 2 bindings) pb (fn pb [bvec b v] (let [pvec (fn [bvec b val] @@ -2491,7 +2495,7 @@ n (nnext bs) true) - (= firstb :as) (pb ret (second bs) gvec) + (= firstb :as) (pb ret (mark-as (second bs)) gvec) :else (if seen-rest? (throw (ex-info "Unsupported binding form, only :as can follow & parameter" {:form bindings})) (recur (pb (if has-rest @@ -2516,7 +2520,7 @@ (conj gmap) (conj `(if (seq? ~gmap) (apply array-map__ (seq ~gmapseq)) ~gmap)) ((fn [ret] (if (:as b) - (conj ret (:as b) gmap) + (conj ret (mark-as (:as b)) gmap) ret)))) bes (let [transforms (reduce diff --git a/core/parse.go b/core/parse.go index d3bd88a5f..1e39a4fa2 100644 --- a/core/parse.go +++ b/core/parse.go @@ -999,7 +999,7 @@ func parseLetLoop(obj Object, isLoop bool, ctx *ParseContext) *LetExpr { if !isSkipUnused(b) { for _, b := range ctx.localBindings.bindings { - if !b.isUsed && !b.name.Equals(SYMBOLS.underscore) { + if !b.isUsed && !b.name.Equals(SYMBOLS.underscore) && !isSkipUnused(b.name) { printParseWarning(GetPosition(b.name), "unused binding: "+b.name.ToString(false)) } } diff --git a/tests/linter/as/.joker b/tests/linter/as/.joker new file mode 100644 index 000000000..a366a6f6d --- /dev/null +++ b/tests/linter/as/.joker @@ -0,0 +1 @@ +{:rules {:unused-as false}} diff --git a/tests/linter/as/input.clj b/tests/linter/as/input.clj new file mode 100644 index 000000000..154da8774 --- /dev/null +++ b/tests/linter/as/input.clj @@ -0,0 +1,2 @@ +(let [{:keys [k] :as m} {}] k) +(let [[f :as v] []] f) diff --git a/tests/linter/as/output.txt b/tests/linter/as/output.txt new file mode 100644 index 000000000..e69de29bb