Workaround to Clojure 1.2 reader bug

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.

Environment

Mac OS X, Clojure 1.2.1, Leiningen 1.6.2

Attachments

1

Activity

Show:

Stuart Sierra January 10, 2014 at 5:26 PM

Mark old resolved issues as 'closed'

import April 24, 2012 at 8:07 PM

Comment made by: sritchie

Great, thanks!

Stuart Sierra April 24, 2012 at 8:04 PM

Patch applied.

Stuart Sierra April 24, 2012 at 8:01 PM

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

Stuart Sierra January 27, 2012 at 3:44 PM

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

Completed

Details

Assignee

Reporter

Patch

Code and Test

Priority

Created December 14, 2011 at 10:52 PM
Updated January 10, 2014 at 5:26 PM
Resolved January 10, 2014 at 5:26 PM