Fork me on GitHub
#planck
<
2017-12-04
>
levitanong00:12:34

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?

mfikes00:12:11

Is the form you ar trying to analyze this?

(defrecord 'Herp ['derp])

levitanong00:12:39

I’m trying to analyze (defrecord Herp [derp])

levitanong00:12:54

I’m quoting it because it ends up getting executed

levitanong00:12:50

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

noisesmith00:12:30

why not (cljs.analyzer/analyze '(defrecord Herp [derp]))

levitanong00:12:54

@noisesmith it results in the stall

levitanong00:12:58

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

levitanong00:12:14

and planck ends up consuming 400% of my cpu

noisesmith00:12:02

when I do that, it returns a lot of analysis data

noisesmith00:12:04

it does not stall

mfikes00:12:58

@noisesmith Are you doing this in JVM ClojureScript?

noisesmith00:12:02

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
....

noisesmith00:12:06

I'm using planck

mfikes00:12:08

In Lumo and Planck, (cljs.analyzer/analyze nil '(defrecord Herp [derp])) derails

noisesmith00:12:30

really? my planck showed many warnings, but also showed results

mfikes00:12:40

Ahh, I'm not patient enough 🙂

noisesmith00:12:47

this was instant

mfikes00:12:25

Are you on Linux?

levitanong00:12:37

ahh, i’m on Mac OS X

mfikes00:12:41

Ubuntu 14.04?

noisesmith00:12:55

yes, that precise one

mfikes00:12:04

@noisesmith What version of ClojureScript do you have in Planck? (`*clojurescript-version*`)

mfikes00:12:56

Perhaps a ClojureScript regression... captured it here https://github.com/mfikes/planck/issues/564

mfikes00:12:32

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.

levitanong01:12:40

@mfikes will you be filing a cljs ticket in JIRA?

mfikes01:12:25

@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

mfikes01:12:58

I think eval-str could be changed to an analyze-str call

levitanong01:12:03

@mfikes will keep an eye out, but I’ll be focusing on a different ticket (something to do with defrecord. :P)

mfikes01:12:27

OK. I think I am able to repro it so will put in a JIRA now

mfikes01:12:26

@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.

levitanong01:12:57

Right, because the defrecord macro is huge

levitanong01:12:46

@mfikes lol that’s pretty cute, I can run (first (cljs.analyzer/analyze nil '(defrecord Herp [derp])))

mfikes01:12:52

Yeah, and (set! *print-level* 15) or some other smallish number can help tame that beast.

levitanong02:12:46

oh, that’s useful. thanks!

mfikes12:12:15

@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))

levitanong12:12:55

oooh, thanks! So cljs.js/empty-state returns an atom?

mfikes12:12:40

Yes, and if in Planck, you should also pass planck.core/init-empty-state. See the docstring for that fn.

levitanong12:12:31

@mfikes what is :dump-core?

levitanong12:12:05

got it, thanks!