Clojure

Fix reader spec and regex to match code for keywords starting with digits

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

The reader page at http://clojure.org/reader states that symbols (and keywords) cannot start with a number and the regex used in LispReader (and EdnReader) also has this intention. CLJ-1252 addressed this by fixing the broken reader regex to match the spec. However, that broke some existing code so we rolled back the change. There is still a disconnect here and this ticket serves to decide what to do instead.

I presume that we are effectively deciding that keywords like :5 are ok to read. If so, we should alter the regex to more accurately capture that intent - right now it allows these purely by accident due to backtracking. A secondary question is whether the Clojure and EDN reader spec should also explicitly allow these as valid. My preference would be to have the reader and the spec match, so I would lobby to loosen the reader spec.

Activity

Alex Miller made changes -
Field Original Value New Value
Labels reader
Hide
Nicola Mometto added a comment - - edited

what about keywords like :1/1 or :1/a? Clojure currently accepts the latter but not the former.

Show
Nicola Mometto added a comment - - edited what about keywords like :1/1 or :1/a? Clojure currently accepts the latter but not the former.
Alex Miller made changes -
Priority Major [ 3 ] Minor [ 4 ]
Hide
Francis Avila added a comment - - edited

There's more discussion of this problem (and symbol/keyword parsing in general) in the context of cljs.reader at CLJS-677.

Show
Francis Avila added a comment - - edited There's more discussion of this problem (and symbol/keyword parsing in general) in the context of cljs.reader at CLJS-677.
Hide
Andy Fingerhut added a comment -

Francis, can you double-check that ticket number? The one you mention (CLJS-667) doesn't seem to have any discussion of this problem.

Show
Andy Fingerhut added a comment - Francis, can you double-check that ticket number? The one you mention (CLJS-667) doesn't seem to have any discussion of this problem.
Hide
Francis Avila added a comment -

Sincere apologies, it's CLJS-677. (Original post corrected too.)

Show
Francis Avila added a comment - Sincere apologies, it's CLJS-677. (Original post corrected too.)

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: