Skip to content

Commit 39aa021

Browse files
puredangerstuarthalloway
authored andcommitted
CLJ-1252 - fix bug in keyword regex that allowed keywords starting with a number
Signed-off-by: Stuart Halloway <[email protected]>
1 parent 26cfee0 commit 39aa021

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/jvm/clojure/lang/EdnReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class EdnReader{
2424

2525
static IFn[] macros = new IFn[256];
2626
static IFn[] dispatchMacros = new IFn[256];
27-
static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^/]].*/)?([\\D&&[^/]][^/]*)");
27+
static Pattern symbolPat = Pattern.compile("[:]?+([\\D&&[^/]].*/)?([\\D&&[^/]][^/]*)");
2828
static Pattern intPat =
2929
Pattern.compile(
3030
"([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?");

src/jvm/clojure/lang/LispReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class LispReader{
5959
static IFn[] macros = new IFn[256];
6060
static IFn[] dispatchMacros = new IFn[256];
6161
//static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^:/]][^:/]*/)?[\\D&&[^:/]][^:/]*");
62-
static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^/]].*/)?(/|[\\D&&[^/]][^/]*)");
62+
static Pattern symbolPat = Pattern.compile("[:]?+([\\D&&[^/]].*/)?(/|[\\D&&[^/]][^/]*)");
6363
//static Pattern varPat = Pattern.compile("([\\D&&[^:\\.]][^:\\.]*):([\\D&&[^:\\.]][^:\\.]*)");
6464
//static Pattern intPat = Pattern.compile("[-+]?[0-9]+\\.?");
6565
static Pattern intPat =

test/clojure/test_clojure/control.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@
324324
:set #{3 2 1}
325325
:set (sorted-set 2 1 3))))
326326
(testing "test number equivalence"
327-
(is (= :1 (case 1N 1 :1 :else))))
327+
(is (= :one (case 1N 1 :one :else))))
328328
(testing "test warn when boxing/hashing expr for all-ints case"
329329
(should-print-err-message
330330
#"Performance warning, .*:\d+ - case has int tests, but tested expression is not primitive..*\r?\n"
@@ -348,10 +348,10 @@
348348
(should-not-reflect (Long. (case 1 1 1))) ; new Long(long)
349349
(should-not-reflect (Long. (case 1 1 "1")))) ; new Long(String)
350350
(testing "non-equivalence of chars and nums"
351-
(are [result input] (= result (case input 97 :97 :else))
351+
(are [result input] (= result (case input 97 :got97 :else))
352352
:else \a
353353
:else (char \a)
354-
:97 (int \a))
354+
:got97 (int \a))
355355
(are [result input] (= result (case input \a :a :else))
356356
:else 97
357357
:else 97N

test/clojure/test_clojure/reader.clj

+3-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@
353353
(are [err msg form] (thrown-with-msg? err msg (read-string form))
354354
Exception #"Invalid token: foo:" "foo:"
355355
Exception #"Invalid token: :bar/" ":bar/"
356-
Exception #"Invalid token: ::does.not/exist" "::does.not/exist"))
356+
Exception #"Invalid token: ::does.not/exist" "::does.not/exist"
357+
Exception #"Invalid token: :5" ":5"))
358+
357359
;; Lists
358360

359361
(deftest t-Lists)

0 commit comments

Comments
 (0)