ClojureDart icon indicating copy to clipboard operation
ClojureDart copied to clipboard

Invalid token error with qualified keywords

Open alidcast opened this issue 2 years ago • 4 comments

i'm writing a macro that uses spec to parse input. qualified keywords are causing cljd to compilation to fail.

few things i've noticed

  • if i comment out the code, run watch, and then added gradually sometimes it compiles 🤷
  • but if code is there on fresh startup, then it errors out predictably

reproduction: https://github.com/aleedmanath/repro-cljd-macros-err note: this reproduction can also be used to test out issue #129

exception that is shown:

error {
 :cause Invalid token: ::spec/example
 :via
 [{:type clojure.lang.ExceptionInfo
   :message Error while host-compiling (ns example.main (:require [example.macros-shim :as m]) (:host-ns (:require [example.macros :as m])))
   :data #:cljd.compiler{:emit-stack [(ns example.main (:require [example.macros-shim :as m]) (:host-ns (:require [example.macros :as m])))]}
   :at [cljd.compiler$host_eval invokeStatic compiler.cljc 2905]}
  {:type clojure.lang.Compiler$CompilerException
   :message Syntax error reading source at (example/macros.clj:7:41).
   :data #:clojure.error{:phase :read-source, :line 7, :column 41, :source example/macros.clj}
   :at [clojure.lang.Compiler load Compiler.java 7643]}
  {:type java.lang.RuntimeException
   :message Invalid token: ::spec/example
   :at [clojure.lang.Util runtimeException Util.java 221]}]

alidcast avatar Jul 13 '22 16:07 alidcast

Thanks for the report ! I’ll take a look on Friday, (maybe tomorrow if I find some time)

dupuchba avatar Jul 13 '22 17:07 dupuchba

more info: :ns/key seems to work, so issue seems to be qualified namespaces, i.e. ::ns/key (notice the double ::)

alidcast avatar Jul 13 '22 18:07 alidcast

I took a look and confirm the error, before diving into the compiler, @cgrand do you have anything that comes to mind ?

dupuchba avatar Jul 15 '22 07:07 dupuchba

Getting back to this

dupuchba avatar Jul 28 '22 07:07 dupuchba