about summary refs log tree commit diff stats
path: root/059shape_shifting_recipe.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-15 01:02:53 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-15 01:02:53 -0800
commit687dd3f5da63bee9dd310bc4ac2844ece43e3fba (patch)
tree3e57d03f17a59c97a9ba10b15ee87084eced66e1 /059shape_shifting_recipe.cc
parentef96f57ce264c8e0bd98f6e8622d1c1e2eceafb2 (diff)
downloadmu-687dd3f5da63bee9dd310bc4ac2844ece43e3fba.tar.gz
2442
Fix the drawback in the previous commit: if an ingredient is just a
literal 0 we'll skip its type-checking and hope to map type ingredients
elsewhere.
Diffstat (limited to '059shape_shifting_recipe.cc')
-rw-r--r--059shape_shifting_recipe.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc
index feffd410..7b2d547d 100644
--- a/059shape_shifting_recipe.cc
+++ b/059shape_shifting_recipe.cc
@@ -37,7 +37,7 @@ if (Current_routine->calls.front().running_step_index == 0
 //: Make sure we don't match up literals with type ingredients without
 //: specialization.
 :(before "End valid_type_for_literal Special-cases")
-if (contains_type_ingredient_name(r)) return false;
+if (contains_type_ingredient_name(lhs)) return false;
 
 //: We'll be creating recipes without loading them from anywhere by
 //: *specializing* existing recipes, so make sure we don't clear any of those
@@ -213,6 +213,7 @@ void compute_type_ingredient_mappings(const recipe& exemplar, const instruction&
     reagent ingredient = inst.ingredients.at(i);
     assert(ingredient.properties.at(0).second);
     canonize_type(ingredient);
+    if (is_mu_address(exemplar_reagent) && ingredient.name == "0") continue;  // assume it matches
     accumulate_type_ingredients(exemplar_reagent, ingredient, mappings, exemplar, inst, caller_recipe, error);
   }
   limit = min(SIZE(inst.products), SIZE(exemplar.products));
@@ -507,3 +508,18 @@ recipe foo x:_elem -> y:_elem [
   y <- add x, 1
 ]
 +mem: storing 4 in location 1
+
+:(scenario specialize_with_literal_3)
+% Hide_errors = true;
+recipe main [
+  local-scope
+  # permit '0' to map to address to shape-shifting type-ingredient
+  1:address:character/raw <- foo 0
+]
+recipe foo x:address:_elem -> y:address:_elem [
+  local-scope
+  load-ingredients
+  y <- copy x
+]
++mem: storing 0 in location 1
+$error: 0