Hi all, I’m running
(cljs.analyzer/analyze nil `(defrecord ~'Herp [~'derp]))` and it's stalling the process. I'm also getting the following warnings:
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing “”
`
Does anyone have any idea what’s going on?Is the form you ar trying to analyze this?
(defrecord 'Herp ['derp])
I’m trying to analyze (defrecord Herp [derp])
I’m quoting it because it ends up getting executed
If i use the backtick, all the symbols get autoresolved, and I get:
WARNING: Use of undeclared Var cljs.user/Herp
Can't def ns-qualified name in namespace ->cljs.user
why not (cljs.analyzer/analyze '(defrecord Herp [derp]))
@noisesmith it results in the stall
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
and planck ends up consuming 400% of my cpu
when I do that, it returns a lot of analysis data
it does not stall
@noisesmith Are you doing this in JVM ClojureScript?
cljs.user=> (cljs.analyzer/analyze nil '(defrecord Herp [derp]))
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or Closure namespace
""
WARNING: Use of undeclared Var /Herp
{:op :let,
:env {:column nil, :line nil},
:bindings [],
:expr {:op :do,
:env {:column nil, :line nil, :context nil},
:form (do
(do
(defrecord*
Herp
[derp]
{0 -2065299702, 1 8192}
(cljs.core$macros/extend-type
Herp
IRecord
ICloneable
(-clone
([this__23818__auto__] (new Herp derp __meta __extmap __hash))
)
IHash
....
I'm using planck
In Lumo and Planck, (cljs.analyzer/analyze nil '(defrecord Herp [derp]))
derails
really? my planck showed many warnings, but also showed results
Ahh, I'm not patient enough 🙂
this was instant
Are you on Linux?
yes
ahh, i’m on Mac OS X
Ubuntu 14.04?
yes, that precise one
@noisesmith What version of ClojureScript do you have in Planck? (`*clojurescript-version*`)
1.9.473
Perhaps a ClojureScript regression... captured it here https://github.com/mfikes/planck/issues/564
:thumbsup:
FWIW, with Planck 1.17 (the last Objective-C version, shipping ClojureScript 1.9.229), (cljs.analyzer/analyze nil '(defrecord Herp [derp]))
is instant as well. I think it is an upstream regression.
@mfikes will you be filing a cljs ticket in JIRA?
@levitanong Yes, if I find evidence that it is upstream (a minimal repro with ClojureScript), I'll log one there. Feel free to try producing a minimal once using the instructions here if you'd like and logging one https://clojurescript.org/community/reporting-bootstrap-issues
I think eval-str
could be changed to an analyze-str
call
@mfikes will keep an eye out, but I’ll be focusing on a different ticket (something to do with defrecord. :P)
OK. I think I am able to repro it so will put in a JIRA now
Thanks, @mfikes!
@levitanong FWIW, it is not the analysis that is the issue, but rather evidently insurmountable difficulty in printing the AST map that is produced. I've revised the ticket.
Right, because the defrecord macro is huge
@mfikes lol that’s pretty cute, I can run (first (cljs.analyzer/analyze nil '(defrecord Herp [derp])))
Yeah, and (set! *print-level* 15)
or some other smallish number can help tame that beast.
oh, that’s useful. thanks!
@levitanong If in self-hosted ClojureScript, an alternative way to analyze, and avoid the warnings that you see when trying to directly call cljs.analyzer/analyze
is to use cljs.js/analyze-str
, especially with the ability to "prime" the compiler state is
(require 'planck.core)
(def ast (cljs.js/analyze-str (cljs.js/empty-state planck.core/init-empty-state) "(defrecord Foo [])" nil {:eval cljs.js/js-eval :context :expr} identity))
oooh, thanks! So cljs.js/empty-state
returns an atom?
Yes, and if in Planck, you should also pass planck.core/init-empty-state
. See the docstring for that fn.
got it, thanks @mfikes!
@mfikes what is :dump-core?
@levitanong See the description of :dump-core
here https://clojurescript.org/guides/self-hosting
got it, thanks!