<< Back to previous view

[CLJS-142] ClojureScript reader throws TypeError when map keys start with colon then number Created: 03/Feb/12  Updated: 27/Jul/13  Resolved: 31/Aug/12

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Murphy McMahon Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

ClojureScript:cljs.user> (cljs.reader/read-string "{:9k true}")
"Error evaluating:" (cljs.reader/read-string "{:9k true}") :as "cljs.reader.read_string.call(null,\"{:9k true}\");\n"
#<TypeError: Cannot read property 'length' of null>
TypeError: Cannot read property 'length' of null
    at http://localhost:8080/javascripts/out/cljs/reader.js:530:38
    at http://localhost:8080/javascripts/out/cljs/reader.js:534:2
    at read_keyword (http://localhost:8080/javascripts/out/cljs/reader.js:547:2)
    at read_delimited_list (http://localhost:8080/javascripts/out/cljs/reader.js:373:32)
    at read_map (http://localhost:8080/javascripts/out/cljs/reader.js:418:47)
    at read (http://localhost:8080/javascripts/out/cljs/reader.js:675:115)
    at read_string (http://localhost:8080/javascripts/out/cljs/reader.js:707:25)
    at eval at <anonymous> (http://localhost:8080/javascripts/out/clojure/browser/repl.js:21:158)
    at eval at <anonymous> (http://localhost:8080/javascripts/out/clojure/browser/repl.js:21:158)
    at http://localhost:8080/javascripts/out/clojure/browser/repl.js:21:153

Comment by Murphy McMahon [ 03/Feb/12 2:21 PM ]

Probably related: the read-string function throws an "Uncaught Invalid number format" for any non-numeric value beginning with a number.

Comment by David Nolen [ 03/Feb/12 7:03 PM ]

After looking over this http://clojure.org/reader I'm not sure that the current behavior is a problem. The fact that keywords that start with numbers happens to work may just be an oversight.

Comment by Murphy McMahon [ 06/Feb/12 12:03 PM ]

OK, I see. I had wanted to use UUIDs as map keys for quick lookups. I'll rethink my approach.

Comment by David Nolen [ 06/Feb/12 5:09 PM ]

You can just use regular Strings, Keywords are an illusion anyhow in ClojureScript.

Comment by Brian Taylor [ 27/May/12 11:40 PM ]


Digging around LispReader.java in clojure, I found the symbol pattern:


Best I can tell, that transcribes directly to the regex the clojurescript reader is using. I'm a bit surprised that clojure allows keywords that start with a number.

I created a Clojure issue mentioning this: CLJ-1003

Comment by David Nolen [ 31/Aug/12 9:43 AM ]

There is no evidence that this allowed.

Generated at Fri Oct 20 14:52:03 CDT 2017 using JIRA 4.4#649-r158309.