Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: Release 1.5
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
-
Approval:Ok
Description
~/clj-git/clojure $ java -cp clojure.jar clojure.main
Clojure 1.3.0-alpha2-SNAPSHOT
user=> (try (catch Exception e (loop [x 0] (recur x))))
CompilerException java.lang.UnsupportedOperationException: Cannot recur from catch/finally, compiling:(NO_SOURCE_PATH:1)
user=> (try (finally (loop [x 0] (if false (recur x)))))
CompilerException java.lang.UnsupportedOperationException: Cannot recur from catch/finally, compiling:(NO_SOURCE_PATH:2)
With attached patch (should also fix CLJ-31):
~/clj-head/clojure $ java -cp clojure.jar clojure.main
Clojure 1.3.0-alpha2-SNAPSHOT
user=> (try (catch Exception e (loop [x 0] (recur x))))
nil
user=> (try (finally (loop [x 0] (if false (recur x)))))
nil
user=> (loop [x 0] (try (if false (recur x))))
CompilerException java.lang.UnsupportedOperationException: Can only recur from tail position, compiling:(NO_SOURCE_PATH:3)
user=> (loop [x 0] (try (catch Exception e (recur x))))
CompilerException java.lang.UnsupportedOperationException: Can only recur from tail position, compiling:(NO_SOURCE_PATH:4)
user=> (loop [x 0] (try (finally (recur x))))
CompilerException java.lang.UnsupportedOperationException: Can only recur from tail position, compiling:(NO_SOURCE_PATH:5)
clj-667-allow-loop-recur-nested-in-catch-and-finally-patch2.txt applies cleanly to latest master as of Feb 24, 2012.
I cannot vouch for the changes in Compiler.java – I simply modified what was in Juha Arpiainen's patch so that they applied cleanly. Some of the context changed noticeably due to a patch for
CLJ-31by Kevin Downey that was applied.The test parts of the patch I can vouch for. Some of the previously existing tests seem not to test what they should. I can make a separate patch with just the updated passing tests if that is desired.
CLJ-31by Kevin Downey that was applied. The test parts of the patch I can vouch for. Some of the previously existing tests seem not to test what they should. I can make a separate patch with just the updated passing tests if that is desired.