tools.namespace

Workaround to Clojure 1.2 reader bug

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Mac OS X, Clojure 1.2.1, Leiningen 1.6.2
  • Patch:
    Code and Test

Description

The clojure 1.2 reader will allow invalid forms like {:key} to be read in, and only throw an exception on printing. Currently clojure.tools.namespace calls (read rdr) within a try form; the bug means that this particular type of error is never caught. This patch forces the reader to try and resolve with str, allowing clojure.tools.namespace to catch and bury the error.

I was running into this with moustache templates from lein-newnew on the classpath; these contain namespace headers that look like (ns name.core). This would cause (clojure.tools.namespace/find-namespaces-on-classpath) to fail when printing its results but not when actually running.

Activity

Hide
Sam Ritchie added a comment -

Funny, jira picked up the moustache markup. a bad namespace looks like (ns { { name } } . core).

Show
Sam Ritchie added a comment - Funny, jira picked up the moustache markup. a bad namespace looks like (ns { { name } } . core).
Hide
Sam Ritchie added a comment -

Ping – Stuart, any thoughts on this?

Show
Sam Ritchie added a comment - Ping – Stuart, any thoughts on this?
Hide
Stuart Sierra added a comment -

Why should tools.ns do this? If the syntax is wrong, it's wrong.

Show
Stuart Sierra added a comment - Why should tools.ns do this? If the syntax is wrong, it's wrong.
Hide
Sam Ritchie added a comment -

Because without this patch, it's impossible to catch and bury errors from invalid reader syntax. I believe this comes from a bug in the reader that was fixed with 1.2.

Show
Sam Ritchie added a comment - Because without this patch, it's impossible to catch and bury errors from invalid reader syntax. I believe this comes from a bug in the reader that was fixed with 1.2.
Hide
Stuart Sierra added a comment -

Declined. It is not the responsibility of this library to catch errors in old versions of Clojure.

Show
Stuart Sierra added a comment - Declined. It is not the responsibility of this library to catch errors in old versions of Clojure.
Hide
Stuart Sierra added a comment -

Reopening because this is still a visible issue for some libraries. I still don't like it, but I'm going to include it.

Show
Stuart Sierra added a comment - Reopening because this is still a visible issue for some libraries. I still don't like it, but I'm going to include it.
Hide
Stuart Sierra added a comment -

Patch applied.

Show
Stuart Sierra added a comment - Patch applied.
Hide
Sam Ritchie added a comment -

Great, thanks!

Show
Sam Ritchie added a comment - Great, thanks!
Hide
Stuart Sierra added a comment -

Mark old resolved issues as 'closed'

Show
Stuart Sierra added a comment - Mark old resolved issues as 'closed'

People

Vote (2)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: