可复现的测试用例
(ns bug)
(require '[clojure.data.xml :as xml] #?@(:cljs [[clojure.data.xml.js.dom :as dom]]))
(def opts {:features #{:clj} :read-cond :allow})
(read-string opts "#?(:cljs {:a ::dom/Element})")
; Execution error at bug/eval30984 (REPL:534).
; Invalid token: ::dom/Element
堆栈跟踪
clojure.lang.Util/runtimeException (Util.java:221)
clojure.lang.LispReader/interpretToken (LispReader.java:412)
clojure.lang.LispReader/read (LispReader.java:305)
clojure.lang.LispReader/readDelimitedList (LispReader.java:1398)
clojure.lang.LispReader$MapReader/invoke (LispReader.java:1355)
clojure.lang.LispReader/read (LispReader.java:285)
clojure.lang.LispReader/access$900 (LispReader.java:41)
clojure.lang.LispReader$ConditionalReader/readCondDelimited (LispReader.java:1584)
clojure.lang.LispReader$ConditionalReader/invoke (LispReader.java:1659)
clojure.lang.LispReader$DispatchReader/invoke (LispReader.java:853)
clojure.lang.LispReader/read (LispReader.java:285)
clojure.lang.RT/readString (RT.java:1876)
clojure.core/read-string (core.clj:3817)
clojure.core/read-string (core.clj:3806)
bug/eval30984 (NO_SOURCE_FILE:534)
clojure.lang.Compiler/eval (Compiler.java:7194)
实际场景
读取 data.xml-0.2.0-alpha8/clojure/data/xml/spec.cljc
时在第 45 行出错:[https://github.com/clojure/data.xml/blob/v0.2.0-alpha8/src/main/resources/clojure/data/xml/spec.cljc#L45](https://github.com/clojure/data.xml/blob/v0.2.0-alpha8/src/main/resources/clojure/data/xml/spec.cljc#L45)
请注意那里的堆栈跟踪是不同的
; Caused by: clojure.lang.ExceptionInfo: [line 45, col 28] Invalid keyword: ::dom/Element. {:type :reader-exception, :ex-kind :reader-error, :file nil, :line 45, :col 28}
; at clojure.tools.reader.impl.errors$throw_ex.invokeStatic(errors.clj:34)
; at clojure.tools.reader.impl.errors$throw_ex.doInvoke(errors.clj:24)
; at clojure.lang.RestFn.invoke(RestFn.java:442)
; at clojure.tools.reader.impl.errors$reader_error.invokeStatic(errors.clj:40)
; at clojure.tools.reader.impl.errors$reader_error.doInvoke(errors.clj:36)
; at clojure.lang.RestFn.invoke(RestFn.java:516)
; at clojure.tools.reader.impl.errors$throw_invalid.invokeStatic(errors.clj:97)
; at clojure.tools.reader.impl.errors$throw_invalid.invoke(errors.clj:96)
; at clojure.tools.reader$read_keyword.invokeStatic(reader.clj:358)
; at clojure.tools.reader$read_keyword.invoke(reader.clj:344)
; at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; at clojure.tools.reader$read_delimited.invokeStatic(reader.clj:198)
; at clojure.tools.reader$read_delimited.invoke(reader.clj:191)
; at clojure.tools.reader$read_list.invokeStatic(reader.clj:209)
; at clojure.tools.reader$read_list.invoke(reader.clj:205)
; at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; at clojure.tools.reader$read_delimited.invokeStatic(reader.clj:198)
; at clojure.tools.reader$read_delimited.invoke(reader.clj:191)
; at clojure.tools.reader$read_list.invokeStatic(reader.clj:209)
; at clojure.tools.reader$read_list.invoke(reader.clj:205)
; at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; at clojure.tools.reader$read_suppress.invokeStatic(reader.clj:451)
; at clojure.tools.reader$read_suppress.invoke(reader.clj:447)
; at clojure.tools.reader$match_feature.invokeStatic(reader.clj:474)
; at clojure.tools.reader$match_feature.invoke(reader.clj:458)
; at clojure.tools.reader$read_cond_delimited$fn__8556.invoke(reader.clj:485)
; at clojure.tools.reader$read_cond_delimited.invokeStatic(reader.clj:480)
; at clojure.tools.reader$read_cond_delimited.invoke(reader.clj:477)
; at clojure.tools.reader$read_cond.invokeStatic(reader.clj:522)
; at clojure.tools.reader$read_cond.invoke(reader.clj:506)
; at clojure.tools.reader$read_dispatch.invokeStatic(reader.clj:72)
; at clojure.tools.reader$read_dispatch.invoke(reader.clj:68)
; at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; at clojure.tools.reader$read.invokeStatic(reader.clj:988)
; at clojure.tools.reader$read.invoke(reader.clj:961)