babashka / nbb

Scripting in Clojure on Node.js using SCI
Eclipse Public License 1.0
863 stars 52 forks source link

Destructuring regression for defmethod #292

Closed cldwalker closed 1 year ago

cldwalker commented 1 year ago

Hi @borkdude. Encountered this bug while upgrading nbb-features. It is easy to work around this destructuring bug but thought you should know


version

1.1.155

platform

osx 12.0.1 and node 16.13.1

problem

When destructuring inside of a defmethod argument, the destructuring bindings are not recognized

repro

nbb-logseq -e "(require '[cljs.test :as t]) (defmethod t/report [::t/default :end-run-tests] [{:keys [error fail]}] (prn :ERR error))"
---- Error --------------------------------------
Message:  Could not resolve symbol: error
Location: 1:102
Phase:    analysis
...

expected behavior

I expected the above to evaluate without error. This evaluates fine with 0.7.135

borkdude commented 1 year ago

Do you have an idea since which version this started happening?

On Fri, 23 Dec 2022 at 03:23, Gabriel Horner @.***> wrote:

Hi @borkdude https://github.com/borkdude. Encountered this bug while upgrading nbb-features https://github.com/babashka/nbb-features/commit/d6b6249cad6d908a25681ee0249762baa872b7b4. It is easy to work around this destructuring bug but thought you should know

version

1.1.155

platform

osx 12.0.1 and node 16.13.1

problem

When destructuring inside of a defmethod argument, the destructuring bindings are not recognized

repro

nbb-logseq -e "(require '[cljs.test :as t]) (defmethod t/report [::t/default :end-run-tests] [{:keys [error fail]}] (prn :ERR error))" ---- Error -------------------------------------- Message: Could not resolve symbol: error Location: 1:102 Phase: analysis ...

expected behavior

I expected the above to evaluate without error. This evaluates fine with 0.7.135

— Reply to this email directly, view it on GitHub https://github.com/babashka/nbb/issues/292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACFSBVT5UDB3CA7NC6O57TWOUEKFANCNFSM6AAAAAATHJXDGM . You are receiving this because you were mentioned.Message ID: @.***>

-- https://www.michielborkent.nl https://www.eetvoorjeleven.nu

borkdude commented 1 year ago

Yeah, this indeed looks weird:

 $ ./cli.js -e "(macroexpand '(defmethod foo ::dude [k {:keys [a]}] a))"
(clojure.core/multi-fn-add-method-impl foo :user/dude (fn* [k {:keys [a]}] a))
cldwalker commented 1 year ago

That was quick. Thanks!