about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-06-25 10:59:20 -0700
committerKartik Agaram <vc@akkartik.com>2018-06-25 10:59:20 -0700
commitb0631dec20089bb142be2ccf28438ebe09489ce5 (patch)
tree0603d66eaf637f7664465cb19ee0b9ce144ff390
parent129a9f71ce0acb5f9156f2a7a1c559fc47ae2e80 (diff)
downloadmu-b0631dec20089bb142be2ccf28438ebe09489ce5.tar.gz
4271 - bugfix unrelated to alloc-ids
-rw-r--r--042name.cc7
-rw-r--r--045closure_name.cc13
2 files changed, 18 insertions, 2 deletions
diff --git a/042name.cc b/042name.cc
index 3078574e..88343495 100644
--- a/042name.cc
+++ b/042name.cc
@@ -40,9 +40,12 @@ void transform_names(const recipe_ordinal r) {
   bool names_used = false;
   bool numeric_locations_used = false;
   map<string, int>& names = Name[r];
-  // store the indices 'used' so far in the map
+  // record the indices 'used' so far in the map
   int& curr_idx = names[""];
-  curr_idx = 2;  // reserve indices 0 and 1 for the chaining slot in a later layer
+  // reserve indices 0 and 1 for the chaining slot in a later layer.
+  // transform_names may get called multiple times in later layers, so
+  // curr_idx may already be set.
+  if (curr_idx < 2) curr_idx = 2;
   for (int i = 0;  i < SIZE(caller.steps);  ++i) {
     instruction& inst = caller.steps.at(i);
     // End transform_names(inst) Special-cases
diff --git a/045closure_name.cc b/045closure_name.cc
index 98bf982c..d1c4859a 100644
--- a/045closure_name.cc
+++ b/045closure_name.cc
@@ -168,3 +168,16 @@ def main [
   3:num/raw <- use-scope 1:space/raw
 ]
 +mem: storing 34 in location 3
+
+:(scenario recursive_transform_names)
+def foo [
+  local-scope
+  x:num <- copy 0
+  return default-space/names:foo
+]
+def main [
+  local-scope
+  0:space/names:foo <- foo
+  x:num/space:1 <- copy 34
+]
+$error: 0