Clojure

Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5, Release 1.6
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    java version "1.6.0_65"
    Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
    Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

    Mac OS X 10.9.1
  • Patch:
    Code and Test
  • Approval:
    Triaged

Description

Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name.

user> (use 'clojure.pprint)
nil
user> (def code '(ns foo.bar))
#'user/code
user> (with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
"(ns foo.barnil)\n"   ;; Expected: {{"(ns foo.bar)\n"}}

Cause: In clojure.pprint/pprint-ns-reference, reference is printed regardless, but may be nil.
Solution: Omit printing reference if nil.
Patch: simple-ns-pprint-fix.patch
Screened by:

Activity

Alex Miller made changes -
Field Original Value New Value
Description Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name. So this:

(def code '(ns foo.bar))
(with-out-str (with-pprint-dispatch code-dispatch (pprint code)))

Will evaluate to "(ns foo.barnil)\n" instead of the correct "(ns foo.bar)\n"

The problem seems to be in the clojure.pprint/pprint-ns-reference function, fix attached.
Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name. So this:

{code}
(def code '(ns foo.bar))
(with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
{code}

Will evaluate to {{"(ns foo.barnil)\n"}} instead of the correct {{"(ns foo.bar)\n"}}

The problem seems to be in the clojure.pprint/pprint-ns-reference function, fix attached.
Labels bug patch print
Alex Miller made changes -
Description Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name. So this:

{code}
(def code '(ns foo.bar))
(with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
{code}

Will evaluate to {{"(ns foo.barnil)\n"}} instead of the correct {{"(ns foo.bar)\n"}}

The problem seems to be in the clojure.pprint/pprint-ns-reference function, fix attached.
Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name. So this:

{code}
user> (use 'clojure.pprint)
nil
user> (def code '(ns foo.bar))
#'user/code
user> (with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
"(ns foo.barnil)\n" ;; Expected: {{"(ns foo.bar)\n"}}
{code}

*Cause:* The problem seems to be in the clojure.pprint/pprint-ns-reference function.

*Patch:* simple-ns-pprint-fix.patch
Alex Miller made changes -
Approval Triaged [ 10120 ]
Alex Miller made changes -
Description Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name. So this:

{code}
user> (use 'clojure.pprint)
nil
user> (def code '(ns foo.bar))
#'user/code
user> (with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
"(ns foo.barnil)\n" ;; Expected: {{"(ns foo.bar)\n"}}
{code}

*Cause:* The problem seems to be in the clojure.pprint/pprint-ns-reference function.

*Patch:* simple-ns-pprint-fix.patch
Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name. So this:

{code}
user> (use 'clojure.pprint)
nil
user> (def code '(ns foo.bar))
#'user/code
user> (with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
"(ns foo.barnil)\n" ;; Expected: {{"(ns foo.bar)\n"}}
{code}

*Cause:* In clojure.pprint/pprint-ns-reference, reference is printed regardless, but may be nil.
*Solution:* Omit printing reference if nil.
*Patch:* simple-ns-pprint-fix.patch
*Screened by:*
Alex Miller made changes -
Description Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name. So this:

{code}
user> (use 'clojure.pprint)
nil
user> (def code '(ns foo.bar))
#'user/code
user> (with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
"(ns foo.barnil)\n" ;; Expected: {{"(ns foo.bar)\n"}}
{code}

*Cause:* In clojure.pprint/pprint-ns-reference, reference is printed regardless, but may be nil.
*Solution:* Omit printing reference if nil.
*Patch:* simple-ns-pprint-fix.patch
*Screened by:*
Pretty printing code using pprint with code-dispatch incorrectly prints a simple ns macro call.
The problem is that "nil" is added to the output after the namespace name.

{code}
user> (use 'clojure.pprint)
nil
user> (def code '(ns foo.bar))
#'user/code
user> (with-out-str (with-pprint-dispatch code-dispatch (pprint code)))
"(ns foo.barnil)\n" ;; Expected: {{"(ns foo.bar)\n"}}
{code}

*Cause:* In clojure.pprint/pprint-ns-reference, reference is printed regardless, but may be nil.
*Solution:* Omit printing reference if nil.
*Patch:* simple-ns-pprint-fix.patch
*Screened by:*

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: