planck

Planck ClojureScript REPL
levitanong 2017-12-04T00:29:34.000076Z

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?

mfikes 2017-12-04T00:32:11.000056Z

Is the form you ar trying to analyze this?

(defrecord 'Herp ['derp])

levitanong 2017-12-04T00:32:39.000060Z

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

levitanong 2017-12-04T00:32:54.000023Z

I’m quoting it because it ends up getting executed

levitanong 2017-12-04T00:33:50.000124Z

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

2017-12-04T00:34:30.000131Z

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

levitanong 2017-12-04T00:34:54.000018Z

@noisesmith it results in the stall

levitanong 2017-12-04T00:34:58.000138Z

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

levitanong 2017-12-04T00:35:14.000048Z

and planck ends up consuming 400% of my cpu

2017-12-04T00:36:02.000021Z

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

2017-12-04T00:36:04.000191Z

it does not stall

mfikes 2017-12-04T00:36:58.000130Z

@noisesmith Are you doing this in JVM ClojureScript?

2017-12-04T00:37:02.000145Z

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

2017-12-04T00:37:06.000075Z

I'm using planck

mfikes 2017-12-04T00:37:08.000056Z

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

2017-12-04T00:37:30.000012Z

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

mfikes 2017-12-04T00:37:40.000105Z

Ahh, I'm not patient enough 🙂

2017-12-04T00:37:47.000066Z

this was instant

mfikes 2017-12-04T00:38:25.000037Z

Are you on Linux?

2017-12-04T00:38:31.000054Z

yes

levitanong 2017-12-04T00:38:37.000021Z

ahh, i’m on Mac OS X

mfikes 2017-12-04T00:38:41.000035Z

Ubuntu 14.04?

2017-12-04T00:39:55.000038Z

yes, that precise one

mfikes 2017-12-04T00:40:04.000020Z

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

2017-12-04T00:40:59.000154Z

1.9.473

mfikes 2017-12-04T00:42:56.000004Z

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

2017-12-04T00:43:39.000124Z

:thumbsup:

mfikes 2017-12-04T00:50:32.000196Z

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.

levitanong 2017-12-04T01:07:40.000183Z

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

mfikes 2017-12-04T01:10:25.000086Z

@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

mfikes 2017-12-04T01:10:58.000016Z

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

levitanong 2017-12-04T01:14:03.000122Z

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

mfikes 2017-12-04T01:14:27.000033Z

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

👍 1
levitanong 2017-12-04T01:27:18.000115Z

Thanks, @mfikes!

mfikes 2017-12-04T01:51:26.000002Z

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

levitanong 2017-12-04T01:51:57.000021Z

Right, because the defrecord macro is huge

levitanong 2017-12-04T01:54:46.000072Z

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

mfikes 2017-12-04T01:57:52.000122Z

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

levitanong 2017-12-04T02:00:46.000037Z

oh, that’s useful. thanks!

mfikes 2017-12-04T12:34:15.000030Z

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

levitanong 2017-12-04T12:35:55.000370Z

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

mfikes 2017-12-04T12:36:40.000140Z

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

levitanong 2017-12-04T12:38:20.000166Z

got it, thanks @mfikes!

levitanong 2017-12-04T12:39:31.000399Z

@mfikes what is :dump-core?

mfikes 2017-12-04T12:41:52.000127Z

@levitanong See the description of :dump-core here https://clojurescript.org/guides/self-hosting

levitanong 2017-12-04T12:42:05.000240Z

got it, thanks!