Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

The cljs compiler errors when trying to emit-constant for a clojure.lang.LazySeq.

Example : https://www.refheap.com/paste/3901

Here syms is defined as a LazySeq on line 3, then on line 7 it is quoted. The error is included in the refheap.

Emitting a cljs.core.list for this type seems to solve the issue.

5 Answers

0 votes
by

Comment made by: dnolen

Can you identify precisely where a LazySeq is getting emitted here? A LazySeq is not literal so this seems like a bug in the macro to me. I could be wrong. Thanks!

0 votes
by

Comment made by: bendlas

The lazy seq seems to be introduced on line 7, the '~syms form

`(let [mappings# (into {} (map-indexed #(identity [%2 %1]) '~syms))

Clojure allows lazy-seqs to be embedded: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L4538

As an aside: The relevant protocol is not literality, but the print-dup multimethod. Do / Should we have print-dup in CLJS?

0 votes
by

Comment made by: bendlas

Attached patch 0001 doesn't add a case for LazySeq, but folds two cases for PersistentList and Cons into one for ISeq.

0 votes
by

Comment made by: dnolen

This approach seems acceptable but this is an old patch can we update for master?

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-349 (reported by julienfantin)
...