Skip to content

Commit 8adf5bc

Browse files
bronsapuredanger
authored andcommitted
CLJ-2521: hoist loop bodies in statement position
1 parent adfad02 commit 8adf5bc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/jvm/clojure/lang/Compiler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6342,7 +6342,7 @@ public Expr parse(C context, Object frm) {
63426342
ISeq body = RT.next(RT.next(form));
63436343

63446344
if(context == C.EVAL
6345-
|| (context == C.EXPRESSION && isLoop))
6345+
|| (context != C.RETURN && isLoop))
63466346
return analyze(context, RT.list(RT.list(FNONCE, PersistentVector.EMPTY, form)));
63476347

63486348
ObjMethod method = (ObjMethod) METHOD.deref();

test/clojure/test_clojure/compilation.clj

+4
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,7 @@
443443
(testing "CLJ-2580 Correctly calculate exit branches of case"
444444
(is (zero? (let [d (case nil :x nil 0)] d)))
445445
(is (nil? (let [d (case nil :x 0 nil)] d)))))
446+
447+
(deftest CLJ-2521
448+
(testing "CLJ-2521 Can nest loop->try when in statement position"
449+
(is (= "ret" ((fn [] (loop [] (try "" (catch Throwable _))) "ret"))))))

0 commit comments

Comments
 (0)