about summary refs log tree commit diff stats
path: root/056shape_shifting_recipe.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-11-10 21:31:01 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-11-10 21:31:01 -0800
commita8aba3ca1210b6c73ee764e8f593a455cb22215a (patch)
tree0a5f92aa5e9cd950a5ea688344e1ff21b4071e1d /056shape_shifting_recipe.cc
parent6e1307c8291d2f42dc17daba3ad78fe1f7c63b69 (diff)
downloadmu-a8aba3ca1210b6c73ee764e8f593a455cb22215a.tar.gz
3661
Another place I missed in commit 3309.
Diffstat (limited to '056shape_shifting_recipe.cc')
-rw-r--r--056shape_shifting_recipe.cc46
1 files changed, 24 insertions, 22 deletions
diff --git a/056shape_shifting_recipe.cc b/056shape_shifting_recipe.cc
index 24304892..c867a12a 100644
--- a/056shape_shifting_recipe.cc
+++ b/056shape_shifting_recipe.cc
@@ -328,36 +328,38 @@ void accumulate_type_ingredients(const type_tree* exemplar_type, const type_tree
     raise << "  (called from '" << to_original_string(call_instruction) << "')\n" << end();
     return;
   }
-  if (is_type_ingredient_name(exemplar_type->name)) {
-    const type_tree* curr_refinement_type = NULL;  // temporary heap allocation; must always be deleted before it goes out of scope
-    if (exemplar_type->atom)
-      curr_refinement_type = new type_tree(*refinement_type);
-    else {
-      assert(!refinement_type->atom);
-      curr_refinement_type = new type_tree(*refinement_type->left);
-    }
-    if (!contains_key(mappings, exemplar_type->name)) {
-      trace(9993, "transform") << "adding mapping from " << exemplar_type->name << " to " << to_string(curr_refinement_type) << end();
-      put(mappings, exemplar_type->name, new type_tree(*curr_refinement_type));
-    }
-    else {
-      if (!deeply_equal_type_names(get(mappings, exemplar_type->name), curr_refinement_type)) {
-        raise << maybe(caller_recipe.name) << "no call found for '" << to_original_string(call_instruction) << "'\n" << end();
-        *error = true;
-        delete curr_refinement_type;
-        return;
+  if (exemplar_type->atom) {
+    if (is_type_ingredient_name(exemplar_type->name)) {
+      const type_tree* curr_refinement_type = NULL;  // temporary heap allocation; must always be deleted before it goes out of scope
+      if (exemplar_type->atom)
+        curr_refinement_type = new type_tree(*refinement_type);
+      else {
+        assert(!refinement_type->atom);
+        curr_refinement_type = new type_tree(*refinement_type->left);
       }
-      if (get(mappings, exemplar_type->name)->name == "literal") {
-        delete get(mappings, exemplar_type->name);
+      if (!contains_key(mappings, exemplar_type->name)) {
+        trace(9993, "transform") << "adding mapping from " << exemplar_type->name << " to " << to_string(curr_refinement_type) << end();
         put(mappings, exemplar_type->name, new type_tree(*curr_refinement_type));
       }
+      else {
+        if (!deeply_equal_type_names(get(mappings, exemplar_type->name), curr_refinement_type)) {
+          raise << maybe(caller_recipe.name) << "no call found for '" << to_original_string(call_instruction) << "'\n" << end();
+          *error = true;
+          delete curr_refinement_type;
+          return;
+        }
+        if (get(mappings, exemplar_type->name)->name == "literal") {
+          delete get(mappings, exemplar_type->name);
+          put(mappings, exemplar_type->name, new type_tree(*curr_refinement_type));
+        }
+      }
+      delete curr_refinement_type;
     }
-    delete curr_refinement_type;
   }
   else {
     accumulate_type_ingredients(exemplar_type->left, refinement_type->left, mappings, exemplar, exemplar_reagent, call_instruction, caller_recipe, error);
+    accumulate_type_ingredients(exemplar_type->right, refinement_type->right, mappings, exemplar, exemplar_reagent, call_instruction, caller_recipe, error);
   }
-  accumulate_type_ingredients(exemplar_type->right, refinement_type->right, mappings, exemplar, exemplar_reagent, call_instruction, caller_recipe, error);
 }
 
 void replace_type_ingredients(recipe& new_recipe, const map<string, const type_tree*>& mappings) {