-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected result for non-tail usage of recur #498
Comments
Note for self:
|
A more efficient way to detect this is using a linter: clj-kondo/clj-kondo#1126 |
I agree that clj-kondo is a nice tool to catch this. Is it already possible to use clj-kondo as a (cljs) library so the linter could be used in other environments? Embedding Sci on a web page for evaluating user code would be an example use case. |
@jeroenvandijk Clj-kondo is currently CLJ only, but portions of it could maybe be ported to CLJS. This is a substantial amount of work though. The way I'm using it currently is as a server side service: https://clj-kondo.michielborkent.nl/ The front-end just sends the code to the backend, the backend lints it and then returns the warnings. |
To be clear, clj-kondo can be used as a JVM library. |
I also hit this problem lately... While linters would be nice, should sci also do something about this? It should be more than a linter warning IMO. |
I will first address this in clj-kondo. I am also contemplating how I could address this in SCI without affecting performance too much. |
It's in clj-kondo now. I'll have a stab at it in SCI soon. |
In babashka master:
|
Already released a while ago. |
version
Babashka 0.2.6 (or 5aa9031)
platform
Mac OSX
problem
loop
/recur
allows recur to be called from a non-tail position. In this particular case this gives unexpected result (doesn't recur) with an error message.repro
expected behavior
Clojure throws an error:
Maybe the clojure behaviour would be most consistent. I'm not sure what the benefits are for not doing this (apart from having to add this check). In this particular case (adding an extra item behind
(recur)
) caught me by surprise.The text was updated successfully, but these errors were encountered: