Skip to content

Commit adf22e6

Browse files
committed
move loop locals into same clearing context as loop body
1 parent 919a710 commit adf22e6

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

src/jvm/clojure/lang/Compiler.java

+27-10
Original file line numberDiff line numberDiff line change
@@ -6017,6 +6017,9 @@ public Expr parse(C context, Object frm) {
60176017
method.locals = backupMethodLocals;
60186018
method.indexlocals = backupMethodIndexLocals;
60196019

6020+
PathNode looproot = new PathNode(PATHTYPE.PATH, (PathNode) CLEAR_PATH.get());
6021+
PathNode clearroot = new PathNode(PATHTYPE.PATH,looproot);
6022+
PathNode clearpath = new PathNode(PATHTYPE.PATH,looproot);
60206023
if(isLoop)
60216024
dynamicBindings = dynamicBindings.assoc(LOOP_LOCALS, null);
60226025

@@ -6049,12 +6052,27 @@ else if(maybePrimitiveType(init) == float.class)
60496052
init = new StaticMethodExpr("", 0, 0, null, RT.class, "doubleCast", RT.vector(init));
60506053
}
60516054
//sequential enhancement of env (like Lisp let*)
6052-
LocalBinding lb = registerLocal(sym, tagOf(sym), init,false);
6053-
BindingInit bi = new BindingInit(lb, init);
6054-
bindingInits = bindingInits.cons(bi);
6055+
try
6056+
{
6057+
if(isLoop)
6058+
{
6059+
Var.pushThreadBindings(
6060+
RT.map(CLEAR_PATH, clearpath,
6061+
CLEAR_ROOT, clearroot,
6062+
NO_RECUR, null));
60556063

6056-
if(isLoop)
6057-
loopLocals = loopLocals.cons(lb);
6064+
}
6065+
LocalBinding lb = registerLocal(sym, tagOf(sym), init,false);
6066+
BindingInit bi = new BindingInit(lb, init);
6067+
bindingInits = bindingInits.cons(bi);
6068+
if(isLoop)
6069+
loopLocals = loopLocals.cons(lb);
6070+
}
6071+
finally
6072+
{
6073+
if(isLoop)
6074+
Var.popThreadBindings();
6075+
}
60586076
}
60596077
if(isLoop)
60606078
LOOP_LOCALS.set(loopLocals);
@@ -6063,11 +6081,10 @@ else if(maybePrimitiveType(init) == float.class)
60636081
try {
60646082
if(isLoop)
60656083
{
6066-
PathNode root = new PathNode(PATHTYPE.PATH, (PathNode) CLEAR_PATH.get());
6067-
Var.pushThreadBindings(
6068-
RT.map(CLEAR_PATH, new PathNode(PATHTYPE.PATH,root),
6069-
CLEAR_ROOT, new PathNode(PATHTYPE.PATH,root),
6070-
NO_RECUR, null));
6084+
Var.pushThreadBindings(
6085+
RT.map(CLEAR_PATH, clearpath,
6086+
CLEAR_ROOT, clearroot,
6087+
NO_RECUR, null));
60716088

60726089
}
60736090
bodyExpr = (new BodyExpr.Parser()).parse(isLoop ? C.RETURN : context, body);

0 commit comments

Comments
 (0)