user defined tagged literal causes failure
Closed this issue · 10 comments
If i have a tagged literal defined for lets say int as #my/int "5" in clojure.
On piggiebacking a clojure repl, the literal is also present in the translated js code and causes parse error e.g.
Mar 31, 2015 2:32:09 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: myproject/.repl-0.0-2665/clojure/browser/event.js:47: ERROR - Parse error. ')' expected
return new cljs.core.PersistentVector(null, #my/int "2", 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k.toLowerCase()),v], null);
Clojure and ClojureScript have completely separate mechanisms for registering tagged literals. Have you done what's necessary to have your tagged literal available to the ClojureScript compiler?
@cemerick yes, i have defined the same literal in clojurescript as well with register-tag-parser!
and in clojure with the usual data_readers.clj.
Here are the tag literal implementations to reproduce this
(register-tag-parser! 'my/int #(js/parseInt %))
(defn- print-int
[^Integer i ^java.io.Writer w]
(.write w (str "#my/int \"" i "\"")))
(defmethod print-method Integer
[^Integer i ^java.io.Writer w]
(print-int i w))
(defmethod print-dup Integer
[^Integer i ^java.io.Writer w]
(print-int i w))
(defn read-int
[^String s]
(Integer. s))
; resources data_readers.clj
; {my/int myns/read-int}
Oh, which version of piggieback are you using? If not the just-released 0.2.0, please give that a shot.
I was on 0.1.3. I am trying to closely follow the wiki for 0.2.0. I have upgrade cljs to 0.0-3165, added tools.nrepl dep. Also did a clean but i am getting the following error
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: cemerick.piggieback/wrap-cljs-repl in this context, compiling:(/tmp/form-init863301719489003663.clj:1:5089)
This is for lein repl
only, the cljs build works fine!
There was a previous issue where it was due to old cljs dep. Still on it will update issue with findings once i get piggieback updated.
Perhaps the nrepl/piggieback deps aren't in your :dev
profile?
Wow how did you guess that?! Ok it was the cause. I am able to get to the repl now. I am using fireplace and issuing :Piggieback 8888
but it throws
IllegalArgumentException No value supplied for key: cljs.repl.browser.BrowserEnv@86701d54 clojure.lang.PersistentHashMap.create (PersistentHashMap.jav a:77)
The usage has changed to match cljs.repl/repl
. No more :repl-env
arg, just (cljs-repl (your-repl-env))
.
I locally patched fireplace to remove :repl-env
but i am afraid the end result is still same. I am getting a few of these
2015-03-31 20:30:41,927 ERROR com.google.javascript.jscomp: myproject/.repl-0.0-3165/clojure/browser/repl.js:14: ERROR - Parse error. ')' expected
return clojure.browser.net.transmit.call(null,conn,new cljs.core.Keyword(null,"print","print",#my/int "1299562414"),cljs.core.pr_str.call(null,data));
This is not a piggieback issue. Seem like defining tagged literal for primitive types will break even pure cljs repls too. On the bright side i got everything updated and made minor patch to fireplace to piggieback with 0.2.0 version. But form evaluations are still failing for me strangely! but cqc
and cqq
works fine.