ClassCastException thrown by heterogenous FSMs
domkm opened this issue · comments
Dom Kiva Meyer commented
(require '[automat.core :as a])
(-> [:a \b]
a/compile
(a/find nil [:a :b]))
;=> java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number
Looks like chars and 1-character strings are coerced to ints: https://github.com/ztellman/automat/blob/8bd3989e0c9d987caafc3b5f0d64e7750d2a3d49/src/automat/core.clj#L19-24
Oddly, this works just fine:
(-> (a/or [:a \b] [:a :b])
a/compile
(a/find nil [:a :b]))
;=> #automat.core.CompiledAutomatonState{:accepted? true, :checkpoint nil, :state-index 2, :start-index 0, :stream-index 2, :value nil}
Dom Kiva Meyer commented
It looks like this patch broke char matching.
(-> [0 :a]
a/compile
(a/find nil [0 :a])
:accepted?)
;=> true
(-> [0 :a \b]
a/compile
(a/find nil [0 :a \b])
:accepted?)
;=> false