This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-24
Channels
- # announcements (31)
- # babashka (21)
- # babashka-sci-dev (4)
- # beginners (8)
- # cherry (4)
- # cider (32)
- # clj-kondo (15)
- # cljdoc (4)
- # cljsrn (4)
- # clojure (69)
- # clojure-dev (1)
- # clojure-europe (12)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-uk (4)
- # clojurescript (16)
- # clr (6)
- # conjure (4)
- # fulcro (4)
- # hispano (1)
- # honeysql (1)
- # humbleui (5)
- # hyperfiddle (8)
- # lambdaisland (4)
- # lsp (8)
- # malli (24)
- # off-topic (3)
- # polylith (5)
- # reagent (10)
- # remote-jobs (3)
- # rewrite-clj (7)
- # scittle (12)
- # spacemacs (4)
- # sql (2)
- # tools-deps (29)
- # xtdb (7)
@lee I ran into an edge case between coercing a node from a string and parsing a node from a string expression.
user=> (require '[rewrite-clj.node :as n])
nil
user=> (n/coerce "foo")
<token: "foo">
user=> (keys (n/coerce "foo"))
(:value :string-value)
;;; vs
user=> (require '[rewrite-clj.parser :as p])
nil
user=> (def node (p/parse-string (pr-str "foo")))
#'user/node
user=> node
<token: "foo">
user=> (keys node)
(:lines)
In clj-kondo I have a predicate string-from-token
which just does :lines
since normally, the string is inside of :lines
but not for coerced string -> nodeThe correct fix might be this:
(extend-protocol NodeCoerceable
String
(coerce [v]
(string-node/string-node v)))
Yeah, there is this issue again, related to what we had earlier:
user=> (node/coerce "\\s")
<token: "\s">
user=> (node/sexpr (node/coerce "\\s"))
Execution error (ExceptionInfo) at clj-kondo.impl.toolsreader.v1v2v2.clojure.tools.reader.impl.errors/throw-ex (errors.clj:26).
Unsupported escape character: \s.
This weirdness may be introduced by read-string-data
. I wonder why rewrite-clj has its own string parsing function, since for the rest of the tokens it just reads the next EDN "token"
@lee I have a preliminary fix here: https://github.com/clj-kondo/clj-kondo/commit/a4c5baea66f4a5f4b9831807d75289930b14f34a I feel like rewrite-clj is adding some unnecessary complexity in this area, but I'm working around it by using the same parsing strategy during coercion as during parsing