Compilation error with nested try/catch/finally

45 views
Skip to first unread message

laurentvaucher

unread,
Jun 9, 2008, 4:49:38 PM6/9/08
to Clojure
I was trying to code a 'with-connection' macro to deal with JDBC
connections and I stumbled upon something that looks like a compiler
error.
It seems the compilers emits invalid bytecode for constructs such as:

(try nil
(finally (try nil
(catch Exception e (println "error")))))

I get a java.lang.VerifyError: Inconsistent stack height 0 != 1


By comparison, the following works:

(try nil
(finally (try nil
(finally (println "error")))))



BTW, try/catch/finally/throw are not currently documented on
clojure.org. Are they meant for external usage?

.Bill Smith

unread,
Jun 9, 2008, 10:31:06 PM6/9/08
to Clojure
try/catch/finally/throw is documented on http://clojure.org/reference/special_forms.html

Bill

Rich Hickey

unread,
Jun 10, 2008, 9:17:23 AM6/10/08
to Clojure


On Jun 9, 4:49 pm, laurentvaucher <laurentvauc...@gmail.com> wrote:
> I was trying to code a 'with-connection' macro to deal with JDBC
> connections and I stumbled upon something that looks like a compiler
> error.
> It seems the compilers emits invalid bytecode for constructs such as:
>
> (try nil
> (finally (try nil
> (catch Exception e (println "error")))))
>
> I get a java.lang.VerifyError: Inconsistent stack height 0 != 1
>

Fixed - thanks for the report.

Rich

mifrai

unread,
Jun 10, 2008, 11:23:13 AM6/10/08
to Clojure
Now I get the same error with a slightly different version of the same
thing...

(try
(try nil
(finally (println "done")))
(catch Exception e nil))

java.lang.VerifyError: (class: clojure/fns/user/fn__1883, method:
invoke signature: ()Ljava/lang/Object;) Inconsistent stack height 1 !=
0

Rich Hickey

unread,
Jun 10, 2008, 11:50:29 AM6/10/08
to Clojure


On Jun 10, 11:23 am, mifrai <mif...@hotmail.com> wrote:
> Now I get the same error with a slightly different version of the same
> thing...
>
> (try
> (try nil
> (finally (println "done")))
> (catch Exception e nil))
>
> java.lang.VerifyError: (class: clojure/fns/user/fn__1883, method:
> invoke signature: ()Ljava/lang/Object;) Inconsistent stack height 1 !=
> 0

laurentvaucher

unread,
Jun 10, 2008, 2:56:17 PM6/10/08
to Clojure
Fixed indeed. That's what I call customer support :o)

Thank you!


Laurent.

Reply all
Reply to author
Forward
0 new messages