rewrite-clj

borkdude 2021-07-24T13:54:31.011100Z

@lee I may have found a bug in rewrite-clj:

user=> (require '[rewrite-clj.node :as node])
nil
user=> (defmacro let+ [local-name binding & body]
  `(let [~local-name ~binding]
     ~@body))
#'user/let+
user=> (node/coerce (macroexpand '(let+ y 1 (+ 1 2 y)))

)
<token: (let* [y 1] (+ 1 2 y))>

borkdude 2021-07-24T13:54:38.011300Z

(token)

lread 2021-07-24T13:57:31.012700Z

Hmmm... thanks very much for the report @borkdude! I shall take a peek sometime this weekend!

borkdude 2021-07-24T13:58:01.012900Z

I will look into it myself too

borkdude 2021-07-24T15:05:53.013200Z

@lee it's a missing NodeCoercable impl on clojure.lang.Cons

borkdude 2021-07-24T15:06:07.013400Z

there are a few more of these types

borkdude 2021-07-24T15:06:12.013600Z

I'll add a PR

borkdude 2021-07-24T15:06:15.013800Z

soonish

lread 2021-07-24T15:08:55.015600Z

Thanks! While I sip my morning coffee, you are being productive!

borkdude 2021-07-24T15:09:07.015900Z

(I'm working in trying to support macros directly in clj-kondo)

borkdude 2021-07-24T15:09:24.016400Z

(which probably won't work very well, but worth a try... again)

borkdude 2021-07-24T15:26:03.017Z

@lee is there something in rewrite-clj like sexpr which adds the location metadata of the node to the sexpr if possible?

borkdude 2021-07-24T15:29:28.017300Z

else I think I would write it myself

lread 2021-07-24T20:11:54.018100Z

@borkdude no, not that I know of!

👍 1
borkdude 2021-07-24T20:22:44.018400Z

@lee for context: https://twitter.com/borkdude/status/1418964404977250313

borkdude 2021-07-24T20:23:27.019300Z

I'm using sexpr + coerce to transform between node -> sexpr -> node so perhaps people can use "normal" macros

borkdude 2021-07-24T20:23:42.019700Z

and still get some precision with respect to locations