summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-05-25 07:05:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-05-25 07:05:23 -0700
commit535999c69576b3e57e35f1936bac852c6aedc983 (patch)
tree61f0ecce088b10802583cd62e73f052b12b02ecd
parentd036239788b1825bfa05588d7f9ee379cd95fc54 (diff)
downloadtxr-535999c69576b3e57e35f1936bac852c6aedc983.tar.gz
txr-535999c69576b3e57e35f1936bac852c6aedc983.tar.bz2
txr-535999c69576b3e57e35f1936bac852c6aedc983.zip
Fix mismanaged dyn_env variable.
* eval.c (bindings_helper): In the parallel binding case, only allocate a new dynamic env when it is needed (because a special variable is being bound), rather than unconditionally. Consequently, only modify dyn_env when the dynamic environment actually needs to be extended. Constructs that use bindings_helper are only wrapped in the dynamic environment save/restore form sys:with-saved-vars if they bind special variables.
-rw-r--r--ChangeLog12
-rw-r--r--eval.c7
2 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 07bacd94..e5d64fb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2015-05-25 Kaz Kylheku <kaz@kylheku.com>
+
+ Fix mismanaged dyn_env variable.
+
+ * eval.c (bindings_helper): In the parallel binding case, only allocate
+ a new dynamic env when it is needed (because a special variable is
+ being bound), rather than unconditionally.
+ Consequently, only modify dyn_env when the dynamic environment actually
+ needs to be extended. Constructs that use bindings_helper are only
+ wrapped in the dynamic environment save/restore form
+ sys:with-saved-vars if they bind special variables.
+
2015-05-22 Kaz Kylheku <kaz@kylheku.com>
Ligher weight debug instrumentation.
diff --git a/eval.c b/eval.c
index 45962114..53da1188 100644
--- a/eval.c
+++ b/eval.c
@@ -1135,7 +1135,7 @@ static val bindings_helper(val vars, val env, val sequential,
val ctx_form)
{
val iter;
- val de = if3(sequential, dyn_env, make_env(nil, nil, dyn_env));
+ val de = if3(sequential, dyn_env, nil);
val ne = if3(sequential, env, make_env(nil, nil, env));
list_collect_decl (new_bindings, ptail);
@@ -1152,7 +1152,8 @@ static val bindings_helper(val vars, val env, val sequential,
if (var == special_s) {
val special = car(item);
- val binding = env_vbind(de, special, value);
+ val binding = env_vbind(de = (de ? de : make_env(nil, nil, dyn_env)),
+ special, value);
if (ret_new_bindings)
ptail = list_collect (ptail, binding);
} else if (bindable(var)) {
@@ -1167,7 +1168,7 @@ static val bindings_helper(val vars, val env, val sequential,
}
}
- if (de != dyn_env)
+ if (de && de != dyn_env)
dyn_env = de;
if (env_out)
*env_out = ne;