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

Activity

Show:
Stuart Sierra
January 27, 2012, 3:44 PM

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

Stuart Sierra
April 24, 2012, 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
April 24, 2012, 8:04 PM

Patch applied.

import
April 24, 2012, 8:07 PM

Comment made by: sritchie

Great, thanks!

Stuart Sierra
January 10, 2014, 5:26 PM

Mark old resolved issues as 'closed'

Assignee

Stuart Sierra

Reporter

import

Labels

None

Approval

None

Patch

Code and Test

Priority

Major
Configure