ont-app / vocabulary

Utilities to map between clojure namespaced keywords and RDF-style URIs
Eclipse Public License 1.0
55 stars 5 forks source link

Error with #voc/lstr Language Tagged Strings in CLJS #32

Open aamedina opened 1 year ago

aamedina commented 1 year ago

Issue: Error with #voc/lstr Reader Macro for Language Tagged Strings in RDF in CLJS

Description

I am encountering an issue when trying to use the #voc/lstr reader macro to support language tagged strings in CLJS. The expected output is not being produced, and instead, I am seeing compile exceptions.

Steps to Reproduce

  1. Run #voc/lstr "hello@en" in a CLJS REPL. This results in a compile exception: failed compiling constant: hello; ont_app.vocabulary.lstr.LangStr is not a valid ClojureScript constant.
  2. Run (ont_app.vocabulary.lstr.LangStr.). This results in #voc/lstrundefined@undefined.
  3. Run (ont-app.vocabulary.lstr.LangStr.). This also results in #voc/lstrundefined@undefined.
  4. Run (ont-app.vocabulary.lstr/->LangStr "hello" "en"). This results in #voc/lstrhello@en.

Expected Behavior

The expected output when running #voc/lstr "hello@en" is #voc/lstr "hello@en".

Actual Behavior

Instead of the expected output, we're seeing compile exceptions and incorrect output.

Additional Information

Thank you for your work on this library.

ont-app commented 1 year ago

Hmm. The unit tests are working. Sorry but I don't play on the cljs side much, and when I do, I typically use shadow. Could you give me instructions for entering the cljs environment that triggers this error?

Thanks for logging this BTW.

aamedina commented 1 year ago

From Emacs I do

M-x cider-jack-in-cljs > figwheel-main > dev

From CLI I do:

clojure -M:dev -m figwheel.main -b dev -r

Everything loads normally in CIDER except the reader macro for the LangStr doesn't print correctly and I can't use the #voc/lstr literals. However in Clojure CLI it works. If I require a namespace (like https://github.com/aamedina/rdf/blob/main/src/cljc/net/wikipunk/rdf/as.cljc) with lstrs I can load it and even see the lstrs but they print malformed as I reported.

ont-app commented 1 year ago

Do you think you could give me a minimal deps.edn?

Also, (ont-app.vocabulary.lstr/->LangStr "hello" "en") should actually be throwing an error. It only expects one argument, e.g. "hello@en"

Edit: sorry, I was working off of memory. You are correct

aamedina commented 1 year ago

Isn't that the constructor for the deftype? It should accept 2 positional args.

{:deps
 {org.clojure/clojure
  {:mvn/version "1.12.0-alpha3"}
  com.cognitect/transit-clj
  {:mvn/version "1.0.333"}
  com.cognitect/transit-cljs
  {:mvn/version "0.8.280"}
  io.github.aamedina/rdf
  {:git/sha "264ac9dbce0ff2f354a3bd0175c56c88abcce882"}
  org.clojure/clojurescript
  {:mvn/version "1.11.60"}
  reagent/reagent
  {:mvn/version "1.2.0"}
  cljsjs/react
  {:mvn/version "17.0.2-0"}
  cljsjs/react-dom
  {:mvn/version "17.0.2-0"}}
 :paths ["src/clj" "src/cljc" "src/cljs" "classes" "resources" "target"]
 :aliases
 {:dev
  {:extra-deps
   {com.bhauman/figwheel-main
    {:mvn/version "0.2.18"}
    com.bhauman/rebel-readline-cljs
    {:mvn/version "0.1.4"}}
   :extra-paths ["dev"]}}}
ont-app commented 1 year ago

I haven't had a chance to really wrestle this problem to the ground, but early indications suggest that this might be a problem with the cider or nrepl render custom tags.

ont-app commented 1 month ago

Traced this to a problem in piggieback.

Logged this issue: https://github.com/nrepl/piggieback/issues/128

aamedina commented 1 month ago

Nice job tracking that down!