GC Issue 27: Disallow recur across try

Description

Reported by richhickey, Jan 01, 2009 Right now will allow: (loop [x 42] (when (pos? x) (binding [*out* *out*] (recur (dec x))))) but the recur doesn't (can't) really happen in the scope of the binding

Environment

None

Attachments

1
  • 20 Nov 2010, 03:46 AM

Activity

Show:

David Miller December 18, 2010 at 2:41 PM

In the tests:

(testing "don't recur to loop from inside try"
(is (thrown? Exception (eval '(loop [x] (try (recur 1)))))))
(testing "don't get confused about what the recur is targeting"
(is (thrown? Exception (eval '(loop [x] (try (fn [x]) (recur 1)))))))

the evals do indeed throw exceptions, but because of the malformed loop expression, not because of the recur-try error.

Kevin Downey November 20, 2010 at 3:46 AM

try #3 at the patch, now with some tests to check that things that are ok to do are still possible

Kevin Downey November 2, 2010 at 9:23 PM

well, dynamic bindings are a try/finally pushing and popping the bindings

Rich Hickey October 30, 2010 at 8:44 PM

It would be nice if the tests confirmed ok things still work, e.g. a full loop/recur inside a try etc

Stuart Halloway October 30, 2010 at 5:29 PM

Patch does two (related) things:

  • throws compile-time exception if you recur across try

  • throws compile-time exception if you recur across dynamic binding

Rich: is this the desired behavior?

Completed

Details

Assignee

Reporter

Approval

Ok

Priority

Fix versions

Created June 17, 2009 at 8:06 PM
Updated December 18, 2010 at 2:41 PM
Resolved December 18, 2010 at 2:41 PM