You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using cljr-expand-let on the let inside of the let value it gets quite confused.
(let [a 1
b (let [c 2]
(+ a c))]
b)
Expected behavior
Any of the following seem reasonable;
(let [a 1
c 2
b (+ a c)]
b)
OR
(let [c 2]
(let [a 1
b (+ a c)]
b)
OR
Throw an error that it can't manipulate this form.
Actual behavior
;; cljr-expand-let at ^(let [c 2]) =>
(let (let [c 2]
[a 1
b (+ a c)])
b)
Which is not valid clojure. I suspect this may be a tricky problem to resolve correctly as the inner let may encodes dependencies on other vars in the outer let, however, I think if the value is inserted as a key in the parent let immediately before this key it should work? I'm also not sure what should happen if the inner let has more then one key and one depends on the other. IE
(let [a 1
b (let [c 2
d (+ a c)]
d)]
b)
I guess maybe the operation should just fold all the keys in the inner let to the outer in order? Like so maybe?
(let [a 1
c 2
d (+ a c)
b d]
b)
Thanks for creating this tool, it's very useful! Also appreciate this particular case is kind of a tricky edge case, but thought it would be useful to report!
When using
cljr-expand-let
on the let inside of the let value it gets quite confused.Expected behavior
Any of the following seem reasonable;
OR
OR
Throw an error that it can't manipulate this form.
Actual behavior
Which is not valid clojure. I suspect this may be a tricky problem to resolve correctly as the inner let may encodes dependencies on other vars in the outer let, however, I think if the value is inserted as a key in the parent let immediately before this key it should work? I'm also not sure what should happen if the inner let has more then one key and one depends on the other. IE
I guess maybe the operation should just fold all the keys in the inner let to the outer in order? Like so maybe?
Thanks for creating this tool, it's very useful! Also appreciate this particular case is kind of a tricky edge case, but thought it would be useful to report!
Steps to reproduce the problem
Use
cljr-expand-let
on the inner let.Environment & Version information
clj-refactor.el version information
clj-refactor 2.5.1 (package: 20210413.733), refactor-nrepl 2.5.1
CIDER version information
Leiningen or Boot version
clojure CLI Version: 1.10.2.774
Emacs version
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2021-04-30
Operating system
Ubuntu 2020.04
The text was updated successfully, but these errors were encountered: