hello, I started using ghostwheel, but I'm trying to write a recursive function and something is getting wrong
I tried this example to simplify the reproduction:
(>defn recursive
[x]
[int? => int?]
(if (> x 0)
(recursive (dec x))
x))
this leads to:
16 | [x]
17 | [int? => int?]
18 | (if (> x 0)
19 | (recursive (dec x))
------------^-------------------------------------------------------------------
Use of undeclared Var com.wsscode.wise.client.ui.structure-importer/recursive
--------------------------------------------------------------------------------
20 | x))
21 |
22 | (defn render-shape!
23 | [this query path]
--------------------------------------------------------------------------------
seems related to tracing feature, when I disabled tracing it compiles fine
@wilkerlucio Can you post your Ghostwheel config here? (Everything relevant / active, external config, ghostwheel.edn, namespace metadata)
Will be releasing 0.4.0 soon, hopefully we can figure this one out quickly and the fix makes it in there.
The simplest explanation off the top of my head is that clairvoyant isn't compatible with recursive functions, which would suck, but let's see. I was just patching a few things there.
By the way, tracing is much improved in 0.4.0, output is much cleaner and more readable and it is more granular as well.
Actually hold off on the config, might be no need, I'm gonna check this with recursive functions in general first.
@wilkerlucio Fixed in 0.4.0 – the tracing code generates 2 different functions in order to be able to dynamically switch between a traced and untraced version at runtime as needed and it broke for recursive functions, because the one defined before was trying to call the one defined after. A simple declare
solved it.
New release coming up in the next few days, maybe tomorrow. If you want to trace until then, just add a simple (declare recursive)
before the (>defn ...
nice! thanks for looking so quickly in it :)
No problem, it was pretty good timing actually, cause I was just knee-deep in the tracing code and rewriting half of it. 🙂
Will announce here, when it's out.