Clojure sometimes throws exceptions that report a line number of 0 when loading a file. This patch changes Compiler.java so the exceptions report the correct line number.

Here's an example:

A test directory containing two libs:

        % ls test
        a.clj  b.clj

test.a requires test.b:

        % cat test/a.clj
        (ns test.a
          (:require test.b))

test.b has an error, its "ns" form on line 6 should not contain the quote:

        % cat test/b.clj
        ; some
        ; very
        ; helpful
        ; comments
        
        (ns 'test.b)
        %

Start Clojure from a freshly built jar with sources from svn:

        % java -cp clojure.jar clojure.main
        Clojure
        user=> (require 'test.a)
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol (b.clj:0)
        user=>

Clojure reports the error, but points to file b.clj, line 0.

[Patch Clojure with the enclosed patch and rebuild clojure.jar.]

        % java -cp clojure.jar clojure.main
        Clojure
        user=> (require 'test.a)
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol (b.clj:6)
        user=>

The line number is reported correctly.

I will attach the patch to this message. If I see that that fails to make it through the google group processing, I'll upload it to the group's file area as compiler-LINE.patch.

--Steve

Attachment: compiler-LINE.patch
Description: Binary data


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to