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.txt
    08/Sep/13 3:40 AM
    2 kB
    Andy Fingerhut
  2. clj-1234-v1.diff
    22/Oct/13 9:09 AM
    2 kB
    Alex Miller

Activity

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)
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.
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!

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: