Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clojurescript warnings with zprint 1.2.0, 1.2.2 #231

Closed
pbwolf opened this issue Apr 2, 2022 · 2 comments
Closed

Clojurescript warnings with zprint 1.2.0, 1.2.2 #231

pbwolf opened this issue Apr 2, 2022 · 2 comments

Comments

@pbwolf
Copy link

pbwolf commented Apr 2, 2022

In a ClojureScript browser REPL arranged by Figwheel, the first example on the page https://github.com/kkinnear/zprint/blob/master/doc/using/repl.md apparently works - but the "require" emits several warnings when I try zprint 1.2.2. I did not see the warnings with zprint 1.1.2. I tried Figwheel's choice of ClojureScript (1.10.773) and also the latest (1.11.4) with similar results.

lein new figwheel-main x
cd x
(insert [zprint "1.2.2"] in project.clj dependencies and update clojurescript to 1.11.4)
lein fig:build
cljs.user=> 42
42
cljs.user=>(require '[zprint.core :as zprint])

Shows at least 100 warnings, including

  • Compile Warning resources/public/cljs-out/dev/rewrite_clj/reader.cljs line:9 column:19: Use of undeclared Var cljs.tools.reader.reader-types/reader-error
  • Compile Warning resources/public/cljs-out/dev/rewrite_clj/reader.cljs line:182 column:14: var: cljs.tools.reader/read-token is not public
  • Compile Warning resources/public/cljs-out/dev/rewrite_clj/reader.cljs line:182 column:13 Wrong number of args (2) passed to cljs.tools.reader/read-token
  • Compile Warning resources/public/cljs-out/dev/rewrite_clj/parser/core.cljs line:149 column:10: var: rewrite-clj.reader/whitespace? is not public
  • Compile Warning resources/public/cljs-out/dev/zprint/comment.cljc line:68 column:22: Use of undeclared Var zprint.comment/left*
  • Compile Warning resources/public/cljs-out/dev/zprint/comment.cljc line:72 column:26: Use of undeclared Var zprint.comment/up*

The first message cites cljs.tools.reader. According to lein deps :tree, org.clojure/clojurescript 1.11.4 entails org.clojure/tools.reader 1.3.3.

@kkinnear
Copy link
Owner

First, my apologies for taking so long to answer this -- I was away for a while. Thank you for submitting this issue.

I have noticed that Figwheel was spitting up errors the first time I used it since I converted to the new parser in 1.2.0, but I thought the warnings were benign since my testing with Figwheel was, I'm chagrined to say, totally inadequate. I was testing only the "structure" printing capability, which works fine despite the warnings. However, using zprint to format anything from a string (i.e., where you say {:parse-string? true}) most certainly did not work. I will ensure my Figwheel testing includes both "structure" and "string" formatting in the future.

I have spent a lot of hours trying to figure out what is going on with Figwheel. Shadow-cljs works fine, with no problems. But maybe my testing there was also inadequate? No, it really does work with no problems. I created some new shadow-cljs tests with a REPL, and they work too. It is just Figwheel.

It took me longer than I'd like to admit to figure out where the cljs compilation results were being cached and generally how to get a Figwheel test to reliably fail. After that, and trying a bunch of other ineffective changes in my code, I finally went to look at the Figwheel classpath. It turns out that com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"} uses the "old" rewrite-cljs parser, while zprint uses the new, merged, rewrite-clj V1 clj/cljs parser.

I have no idea what the parser is used for in rebel-readline-cljs. If I leave it out:

{:deps {com.bhauman/figwheel-main {:mvn/version "0.2.16"},
        #_com.bhauman/rebel-readline-cljs #_{:mvn/version "0.1.4"},
        org.clojure/clojure {:mvn/version "1.11.1"},
        org.clojure/clojurescript {:mvn/version "1.11.4"},
        zprint/zprint {:mvn/version "1.2.2"}},
 ;; setup some development paths
 :paths ["src" "target" "resources"],
 ;; setup a helpful alias to start the build
 :aliases {:build-dev {:main-opts ["-m" "figwheel.main" "-r"]}}}

There are two or three warnings at the beginning unrelated to zprint, but zprint works fine for both structures and string formatting. No errors on (require 'zprint.core) and (zprint.core/czprint "(a b c)" {:parse-string? true}) works!

In addition, if I exclude rewrite-cljs, like this:

{:deps {com.bhauman/figwheel-main {:mvn/version "0.2.16"},
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4" :exclusions [rewrite-cljs/rewrite-cljs]},
        org.clojure/clojure {:mvn/version "1.11.1"},
        org.clojure/clojurescript {:mvn/version "1.11.4"},
        zprint/zprint {:mvn/version "1.2.2"}},
 ;; setup some development paths
 :paths ["src" "target" "resources"],
 ;; setup a helpful alias to start the build
 :aliases {:build-dev {:main-opts ["-m" "figwheel.main" "-r"]}}}

It also works:

[...]
Prompt will show when REPL connects to evaluation environment (i.e. a REPL hosting webpage)
Figwheel Main Controls:
          (figwheel.main/stop-builds id ...)  ;; stops Figwheel autobuilder for ids
          (figwheel.main/start-builds id ...) ;; starts autobuilder focused on ids
          (figwheel.main/reset)               ;; stops, cleans, reloads config, and starts autobuilder
          (figwheel.main/build-once id ...)   ;; builds source one time
          (figwheel.main/clean id ...)        ;; deletes compiled cljs target files
          (figwheel.main/status)              ;; displays current state of system
Figwheel REPL Controls:
          (figwheel.repl/conns)               ;; displays the current connections
          (figwheel.repl/focus session-name)  ;; choose which session name to focus on
In the cljs.user ns, controls can be called without ns ie. (conns) instead of (figwheel.repl/conns)
    Docs: (doc function-name-here)
    Exit: :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
[Rebel readline] Type :repl/help for online help info
Opening URL http://localhost:9500
ClojureScript 1.11.4
cljs.user=> (require 'zprint.core)
nil
cljs.user=> (in-ns 'zprint.core)

zprint.core=> (czprint "(a b c)" {:parse-string? true})
(a b c)
nil
zprint.core=>

I don't know if there is some lurking issue here, where rebel-readline will fail at some point because it isn't getting linked up right with rewrite-cljs, or if it is getting linked to rewrite-clj correctly and everything will work. I'd probably try the deps.edn above with the :exclusions and if, down the road, something failed, then maybe drop down to the deps.edn without rebel-readline at all. But rebel-readline seems like it has a lot of useful stuff in it.

All of this may just be to remove the errors when you start Figwheel, since you may well be using zprint just to print structures, which I believe it does correctly even with the hundreds of errors.

Hopefully one of the two deps.edn approaches above will solve your problem -- please let me know if this doesn't make the errors from zprint go away!

Thanks again for pointing out this issue. It is good to have figured it out (finally), and also very good to up my Figwheel testing game.

@kkinnear
Copy link
Owner

The docs were updated for 1.2.3. There continue to be aggravating and difficult to track down and resolve build issues with Figwheel. See Issue #246 for another related problem and solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants