This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-06-05
Channels
- # aleph (4)
- # announcements (2)
- # aws (37)
- # babashka (20)
- # beginners (105)
- # calva (30)
- # cider (6)
- # clerk (8)
- # cljs-dev (2)
- # clojars (8)
- # clojure (18)
- # clojure-brasil (1)
- # clojure-europe (25)
- # clojure-nl (1)
- # clojure-norway (21)
- # clojure-sweden (7)
- # clojure-uk (5)
- # clr (2)
- # cursive (37)
- # datalevin (2)
- # emacs (6)
- # events (2)
- # graalvm (35)
- # graphql (1)
- # hyperfiddle (3)
- # lsp (4)
- # malli (1)
- # off-topic (7)
- # pedestal (7)
- # practicalli (8)
- # reitit (5)
- # releases (4)
- # remote-jobs (1)
- # shadow-cljs (15)
- # xtdb (19)
I wrote about this about a year ago, but didn't get a response. I'm revisiting this again. I've written a custom reader tag called #voc/lstr which behaves like this in the JVM repl:
> (def x #voc/lstr "gaol@en-uk")
> x
#voc/lstr "gaol@en-uk"
> (type x)
ont_app.vocabulary.lstr.LangStr
> (str x)
"gaol"
> (ont-app.vocabulary.lstr/lang x)
"en-uk"
This also works when I launch a cljs repl using clojure -M:test -m cljs.main
, with this difference (note ont_app
vs ont-app
):
(type #voc/lstr "gaol@en-uk")
ont-app.vocabulary.lstr/LangStr
However, when I launch cider-jack-in-cljs
with REPL type node
, I get the following behavior:
;; Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"} cider/cider-nrepl {:mvn/version "0.30.0"} cider/piggieback {:mvn/version "0.5.2"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}' -Mdev:cider/nrepl
;;
;; ClojureScript REPL type: node
;; ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
;;
> #voc/lstr "gaol@en"
Unexpected error (ExceptionInfo) compiling at (REPL:1).
failed compiling constant: gaol; ont_app.vocabulary.lstr.LangStr is not a valid ClojureScript constant.
The problem seems to arise from the fact that the cljs.compiler/emit-constant* method is dispatched under ont-app.vocabulary.lstr/LangStr
, but the compiler is looking for ont_app.vocabulary.lstr/LangStr
.
I have the impression that the problem is originating somewhere in here:
https://github.com/nrepl/piggieback/blob/master/src/cider/piggieback_impl.clj
(defn read-cljs-string [form-str]
(when-not (string/blank? form-str)
(binding [*ns* (create-ns ana/*cljs-ns*)
reader/resolve-symbol ana/resolve-symbol
reader/*data-readers* tags/*cljs-data-readers*
reader/*alias-map*
(apply merge
((juxt :requires :require-macros)
(ana/get-namespace ana/*cljs-ns*)))]
(reader/read {:read-cond :allow :features #{:cljs}}
(readers/source-logging-push-back-reader
(java.io.StringReader. form-str))))))
But I don't really play much on the CLJS side of things, and I'm unclear as to how one gets visibility into compilation in a clojurescript REPL.
Am I correct in the impression that this is a bug in piggieback, and would I be off-base if I logged an issue with them?In https://github.com/nrepl/piggieback/blob/540a57e871b72cb494d0049cb8c6b7485458ad25/src/cider/piggieback_impl.clj#L213 we only use the value of tags/*cljs-data-readers*
while in the official clojurescript compiler/repl, they use:
(merge tags/*cljs-data-readers*
(ana/load-data-readers))
So probably we need to imitate that patternI'd suggest that you clone piggieback, add that change, perform a lein install, and try if it works.
I can help making the lein install
easier (we normally have it as a Makefile task but it's not there)
I'm about to commit a bunch of changes after being away from the project for a long time, but the current version should also have this problem: https://github.com/ont-app/vocabulary
Thanks I'll try cloning and making that change.
I'm about to commit a bunch of changes after being away from the project for a long time, but the current version should also have this problem: https://github.com/ont-app/vocabulary