Clojure

Accept whitespace in Record and Type reader forms

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Whitespace should be allowed in the record reader form as with tagged literals. Following example shows the problem:

user=> *clojure-version*
{:major 1, :minor 5, :incremental 1, :qualifier nil}
user=> (defrecord B [x])
user.B
user=> (B. 2)
#user.B{:x 2}
user=> #user.B{:x 3}
#user.B{:x 3}
user=> #user.B {:x 3}
RuntimeException Unreadable constructor form starting with "#user.B "  clojure.lang.Util.runtimeException (Util.java:219)
user=> #inst "2013"
#inst "2013-01-01T00:00:00.000-00:00"
user=> #inst"2013"
#inst "2013-01-01T00:00:00.000-00:00"

Patch: clj-1234-v1.diff

Screened by: Alex Miller

  1. clj-1234-v1.diff
    22/Oct/13 9:09 AM
    2 kB
    Alex Miller
  2. clj-1234-v1.txt
    08/Sep/13 3:40 AM
    2 kB
    Andy Fingerhut

Activity

Alex Miller made changes -
Field Original Value New Value
Approval Triaged [ 10120 ]
Alex Miller made changes -
Issue Type Enhancement [ 4 ] Defect [ 1 ]
Alex Miller made changes -
Description In order to bring back together record reader forms with tagged literals, it is needed to allow whitespace in the record reader forms. Following example shows the problem
{code}
user=> *clojure-version*
{:major 1, :minor 5, :incremental 1, :qualifier nil}
user=> (defrecord B [x])
user.B
user=> (B. 2)
#user.B{:x 2}
user=> #user.B{:x 3}
#user.B{:x 3}
user=> #user.B {:x 3}
RuntimeException Unreadable constructor form starting with "#user.B " clojure.lang.Util.runtimeException (Util.java:219)
user=> #inst "2013"
#inst "2013-01-01T00:00:00.000-00:00"
user=> #inst"2013"
#inst "2013-01-01T00:00:00.000-00:00"
{code}
Whitespace should be allowed in the record reader form as with tagged literals. Following example shows the problem:

{code}
user=> *clojure-version*
{:major 1, :minor 5, :incremental 1, :qualifier nil}
user=> (defrecord B [x])
user.B
user=> (B. 2)
#user.B{:x 2}
user=> #user.B{:x 3}
#user.B{:x 3}
user=> #user.B {:x 3}
RuntimeException Unreadable constructor form starting with "#user.B " clojure.lang.Util.runtimeException (Util.java:219)
user=> #inst "2013"
#inst "2013-01-01T00:00:00.000-00:00"
user=> #inst"2013"
#inst "2013-01-01T00:00:00.000-00:00"
{code}
Hide
Alex Miller added a comment -

Stack trace in case it's useful:

user=> (pst *e)
ReaderException java.lang.RuntimeException: Unreadable constructor form starting with "#user.B "
clojure.lang.LispReader.read (LispReader.java:220)
clojure.core/read (core.clj:3407)
clojure.core/read (core.clj:3405)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn-589/fn-592 (interruptible_eval.clj:52)
clojure.main/repl/read-eval-print-6588/fn-6589 (main.clj:257)
clojure.main/repl/read-eval-print--6588 (main.clj:257)
clojure.main/repl/fn--6597 (main.clj:277)
clojure.main/repl (main.clj:277)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn--589 (interruptible_eval.clj:56)
clojure.core/apply (core.clj:617)
clojure.core/with-bindings* (core.clj:1788)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:41)
Caused by:
RuntimeException Unreadable constructor form starting with "#user.B "
clojure.lang.Util.runtimeException (Util.java:219)
clojure.lang.LispReader$CtorReader.readRecord (LispReader.java:1224)
clojure.lang.LispReader$CtorReader.invoke (LispReader.java:1174)
clojure.lang.LispReader$DispatchReader.invoke (LispReader.java:619)
clojure.lang.LispReader.read (LispReader.java:185)
clojure.core/read (core.clj:3407)

Show
Alex Miller added a comment - Stack trace in case it's useful: user=> (pst *e) ReaderException java.lang.RuntimeException: Unreadable constructor form starting with "#user.B " clojure.lang.LispReader.read (LispReader.java:220) clojure.core/read (core.clj:3407) clojure.core/read (core.clj:3405) clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn-589/fn-592 (interruptible_eval.clj:52) clojure.main/repl/read-eval-print-6588/fn-6589 (main.clj:257) clojure.main/repl/read-eval-print--6588 (main.clj:257) clojure.main/repl/fn--6597 (main.clj:277) clojure.main/repl (main.clj:277) clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn--589 (interruptible_eval.clj:56) clojure.core/apply (core.clj:617) clojure.core/with-bindings* (core.clj:1788) clojure.tools.nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:41) Caused by: RuntimeException Unreadable constructor form starting with "#user.B " clojure.lang.Util.runtimeException (Util.java:219) clojure.lang.LispReader$CtorReader.readRecord (LispReader.java:1224) clojure.lang.LispReader$CtorReader.invoke (LispReader.java:1174) clojure.lang.LispReader$DispatchReader.invoke (LispReader.java:619) clojure.lang.LispReader.read (LispReader.java:185) clojure.core/read (core.clj:3407)
Alex Miller made changes -
Labels reader
Rich Hickey made changes -
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Fix Version/s Release 1.6 [ 10157 ]
Hide
Andy Fingerhut added a comment -

Patch clj-1234-v1.txt adds a test that fails without the patch, and passes with it, verifying that white space is allowed after #record.name but before {.

Very straightforward patch, especially since fogus was nice enough to write 2 commented-out lines that did the trick simply by uncommenting them.

Show
Andy Fingerhut added a comment - Patch clj-1234-v1.txt adds a test that fails without the patch, and passes with it, verifying that white space is allowed after #record.name but before {. Very straightforward patch, especially since fogus was nice enough to write 2 commented-out lines that did the trick simply by uncommenting them.
Andy Fingerhut made changes -
Attachment clj-1234-v1.txt [ 12248 ]
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]
Hide
Alex Miller added a comment -

Any LispReader fix likely also affects EdnReader.

Show
Alex Miller added a comment - Any LispReader fix likely also affects EdnReader.
Hide
Nicola Mometto added a comment -

EdnReader doesn't read record/type literals so in this case it's not affected

Show
Nicola Mometto added a comment - EdnReader doesn't read record/type literals so in this case it's not affected
Hide
Alex Miller added a comment -

Thanks for checking!

Show
Alex Miller added a comment - Thanks for checking!
Alex Miller made changes -
Approval Vetted [ 10003 ] Screened [ 10004 ]
Description Whitespace should be allowed in the record reader form as with tagged literals. Following example shows the problem:

{code}
user=> *clojure-version*
{:major 1, :minor 5, :incremental 1, :qualifier nil}
user=> (defrecord B [x])
user.B
user=> (B. 2)
#user.B{:x 2}
user=> #user.B{:x 3}
#user.B{:x 3}
user=> #user.B {:x 3}
RuntimeException Unreadable constructor form starting with "#user.B " clojure.lang.Util.runtimeException (Util.java:219)
user=> #inst "2013"
#inst "2013-01-01T00:00:00.000-00:00"
user=> #inst"2013"
#inst "2013-01-01T00:00:00.000-00:00"
{code}
Whitespace should be allowed in the record reader form as with tagged literals. Following example shows the problem:

{code}
user=> *clojure-version*
{:major 1, :minor 5, :incremental 1, :qualifier nil}
user=> (defrecord B [x])
user.B
user=> (B. 2)
#user.B{:x 2}
user=> #user.B{:x 3}
#user.B{:x 3}
user=> #user.B {:x 3}
RuntimeException Unreadable constructor form starting with "#user.B " clojure.lang.Util.runtimeException (Util.java:219)
user=> #inst "2013"
#inst "2013-01-01T00:00:00.000-00:00"
user=> #inst"2013"
#inst "2013-01-01T00:00:00.000-00:00"
{code}

*Patch:* clj-1234-v1.tx

*Screened by:* Alex Miller
Alex Miller made changes -
Description Whitespace should be allowed in the record reader form as with tagged literals. Following example shows the problem:

{code}
user=> *clojure-version*
{:major 1, :minor 5, :incremental 1, :qualifier nil}
user=> (defrecord B [x])
user.B
user=> (B. 2)
#user.B{:x 2}
user=> #user.B{:x 3}
#user.B{:x 3}
user=> #user.B {:x 3}
RuntimeException Unreadable constructor form starting with "#user.B " clojure.lang.Util.runtimeException (Util.java:219)
user=> #inst "2013"
#inst "2013-01-01T00:00:00.000-00:00"
user=> #inst"2013"
#inst "2013-01-01T00:00:00.000-00:00"
{code}

*Patch:* clj-1234-v1.tx

*Screened by:* Alex Miller
Whitespace should be allowed in the record reader form as with tagged literals. Following example shows the problem:

{code}
user=> *clojure-version*
{:major 1, :minor 5, :incremental 1, :qualifier nil}
user=> (defrecord B [x])
user.B
user=> (B. 2)
#user.B{:x 2}
user=> #user.B{:x 3}
#user.B{:x 3}
user=> #user.B {:x 3}
RuntimeException Unreadable constructor form starting with "#user.B " clojure.lang.Util.runtimeException (Util.java:219)
user=> #inst "2013"
#inst "2013-01-01T00:00:00.000-00:00"
user=> #inst"2013"
#inst "2013-01-01T00:00:00.000-00:00"
{code}

*Patch:* clj-1234-v1.diff

*Screened by:* Alex Miller
Attachment clj-1234-v1.diff [ 12362 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: