Skip to content

Custom data readers do not appear to be supported. #128

@ont-app

Description

@ont-app

I have defined a custom reader macro that is supported elsewhere in the cljs infrastructure, but does not work in the Cider REPL.

> #voc/lstr "gaol@en-uk"
Unexpected error (ExceptionInfo) compiling at (REPL:1).
failed compiling constant: gaol; ont_app.vocabulary.lstr.LangStr is not a valid ClojureScript constant.

It has been hypothesized that this code might fix the problem:

(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* (merge tags/*cljs-data-readers*
                                                   (ana/load-data-readers))  ;; <<<<< note this change
              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))))))

I cloned the project and attempted to try it, but ran into technical difficulties I couldn't resolve.

See this discussion on Slack for context:

https://clojurians.slack.com/archives/C0617A8PQ/p1717590636580699

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions