Skip to content

Commit

Permalink
Fix parsing of b// symbol (#324)
Browse files Browse the repository at this point in the history
Fixes #323
  • Loading branch information
borkdude authored Nov 18, 2024
1 parent b8a4804 commit 3910e20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 `~@`
Expand Down
8 changes: 4 additions & 4 deletions src/rewrite_clj/reader.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/rewrite_clj/parser_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 3910e20

Please sign in to comment.