[CLJS-817] Warning on use of undeclared var when creating recursive definition Created: 17/Jun/14 Updated: 01/Jul/14 Resolved: 01/Jul/14
If you create a definition that recursively refers to itself, a warning is issued. This is simply a warning; the generated code still works. The same code works without such a warning in Clojure.
Here is an example:
(def fib-seq (lazy-cat [0 1] (map + (rest fib-seq) fib-seq)))
This generates the following warning:
Compiling "js/main.js" from ["src/cljs" "src/clj"]...
|Comment by Mike Fikes [ 17/Jun/14 7:09 PM ]|
An easy workaround is to forward declare. For the example given in the description,
|Comment by David Nolen [ 19/Jun/14 10:49 AM ]|
Would be happy to take a patch that propagates the def'ed var so that the initializer expression has it during analysis.
|Comment by Mike Fikes [ 19/Jun/14 3:58 PM ]|
Note that I'm a new contributor (I signed the online CLA), but I have no experience with the ClojureScript compiler codebase. In other words, increased review for this patch is appropriate IMHO.
|Comment by David Nolen [ 19/Jun/14 4:45 PM ]|
The patch initially looks OK will give a closer look tomorrow. Thanks!
|Comment by Mike Fikes [ 20/Jun/14 9:54 AM ]|
Thanks David. Let me know if the patch could use further work. Glad to revise as necessary.
|Comment by David Nolen [ 01/Jul/14 9:31 PM ]|