From 3910e2054695dc130fad5f4056052544d42a670f Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 18 Nov 2024 13:52:06 +0100 Subject: [PATCH] Fix parsing of b// symbol (#324) Fixes #323 --- CHANGELOG.adoc | 2 ++ src/rewrite_clj/reader.cljc | 8 ++++---- test/rewrite_clj/parser_test.cljc | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c0ac35d..154cdfb 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -24,6 +24,8 @@ A release with known breaking changes is marked with: // (adjust these in publish.clj as you see fit) === Unreleased +* Fix parsing of `b//` symbol +{issue}323[#323] ({borkdude}) * bump `org.clojure/tools.reader` to version `1.5.0` ({lread}) * `sexpr` now better matches clojure `read-string` for `~`, `@` and `~@` diff --git a/src/rewrite_clj/reader.cljc b/src/rewrite_clj/reader.cljc index 5790e77..d3819fa 100644 --- a/src/rewrite_clj/reader.cljc +++ b/src/rewrite_clj/reader.cljc @@ -223,13 +223,13 @@ [ns sym] (and (not (interop/numeric? (nth sym 0))) - (not (identical? "" sym)) + (not (= "" sym)) (not (string/ends-with? ns ":")) - (or (identical? sym "/") + (or (= sym "/") (nil? (string/index-of sym "/")))) [ns sym])))) - (when (or (identical? token "/") - (nil? (string/index-of token "/"))) + (when (or (= token "/") + (nil? (string/index-of token "/"))) [nil token])))) (defn read-symbol diff --git a/test/rewrite_clj/parser_test.cljc b/test/rewrite_clj/parser_test.cljc index d2bce7e..dcb0143 100644 --- a/test/rewrite_clj/parser_test.cljc +++ b/test/rewrite_clj/parser_test.cljc @@ -63,7 +63,8 @@ ["sym'" 'sym'] ["sym'sym" 'sym'sym] ["sym:sym" 'sym:sym] - ["\"string\"" "string"]]] + ["\"string\"" "string"] + ["b//" 'b//]]] (let [n (p/parse-string s)] (is (= :token (node/tag n))) (is (= s (node/string n)))