about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--018type_abbreviations.cc5
-rw-r--r--052tangle.cc9
-rw-r--r--056shape_shifting_recipe.cc25
-rw-r--r--075channel.mu4
4 files changed, 36 insertions, 7 deletions
diff --git a/018type_abbreviations.cc b/018type_abbreviations.cc
index f7fd0592..1f33a5a6 100644
--- a/018type_abbreviations.cc
+++ b/018type_abbreviations.cc
@@ -164,7 +164,10 @@ Transform.push_back(expand_type_abbreviations);  // idempotent
 
 :(code)
 void expand_type_abbreviations(const recipe_ordinal r) {
-  const recipe& caller = get(Recipe, r);
+  expand_type_abbreviations(get(Recipe, r));
+}
+
+void expand_type_abbreviations(const recipe& caller) {
   trace(9991, "transform") << "--- expand type abbreviations in recipe '" << caller.name << "'" << end();
   for (int i = 0; i < SIZE(caller.steps); ++i) {
     const instruction& inst = caller.steps.at(i);
diff --git a/052tangle.cc b/052tangle.cc
index 73f047f2..b60105fa 100644
--- a/052tangle.cc
+++ b/052tangle.cc
@@ -72,6 +72,7 @@ void insert_fragments(const recipe_ordinal r) {
 }
 
 void insert_fragments(recipe& r) {
+  trace(9991, "transform") << "--- insert fragments into recipe " << r.name << end();
   bool made_progress = true;
   int pass = 0;
   while (made_progress) {
@@ -91,11 +92,15 @@ void insert_fragments(recipe& r) {
       prefix << '+' << r.name << '_' << pass << '_' << i;
       // ok to use contains_key even though Before_fragments uses [],
       // because appending an empty recipe is a noop
-      if (contains_key(Before_fragments, inst.label))
+      if (contains_key(Before_fragments, inst.label)) {
+        trace(9992, "transform") << "insert fragments before label " << inst.label << end();
         append_fragment(result, Before_fragments[inst.label].steps, prefix.str());
+      }
       result.push_back(inst);
-      if (contains_key(After_fragments, inst.label))
+      if (contains_key(After_fragments, inst.label)) {
+        trace(9992, "transform") << "insert fragments after label " << inst.label << end();
         append_fragment(result, After_fragments[inst.label].steps, prefix.str());
+      }
     }
     r.steps.swap(result);
     ++pass;
diff --git a/056shape_shifting_recipe.cc b/056shape_shifting_recipe.cc
index 2a91723c..fd1190ce 100644
--- a/056shape_shifting_recipe.cc
+++ b/056shape_shifting_recipe.cc
@@ -249,7 +249,9 @@ recipe_ordinal new_variant(recipe_ordinal exemplar, const instruction& inst, con
   // a) perform tangle *before* replacing type ingredients, just in case
   // inserted code involves type ingredients
   insert_fragments(new_recipe);
-  // b) do the work of check_types_by_name while supporting type-ingredients
+  // b) do the work of check_or_set_types_by_name (and its prerequisites)
+  // while supporting type-ingredients
+  expand_type_abbreviations(new_recipe);
   compute_type_names(new_recipe);
   // that gives enough information to replace type-ingredients with concrete types
   {
@@ -268,7 +270,7 @@ recipe_ordinal new_variant(recipe_ordinal exemplar, const instruction& inst, con
 }
 
 void compute_type_names(recipe& variant) {
-  trace(9993, "transform") << "compute type names: " << variant.name << end();
+  trace(9993, "transform") << "-- compute type names: " << variant.name << end();
   map<string, type_tree*> type_names;
   for (int i = 0; i < SIZE(variant.ingredients); ++i)
     save_or_deduce_type_name(variant.ingredients.at(i), type_names, variant, "");
@@ -479,6 +481,7 @@ void dump_inspect(const type_tree* x, ostream& out) {
 }
 
 void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemplar) {
+  trace(9993, "transform") << "-- ensure all concrete types in recipe " << new_recipe.name << end();
   for (int i = 0; i < SIZE(new_recipe.ingredients); ++i)
     ensure_all_concrete_types(new_recipe.ingredients.at(i), exemplar);
   for (int i = 0; i < SIZE(new_recipe.products); ++i)
@@ -1050,6 +1053,24 @@ def main [
 ]
 $error: 0
 
+:(scenario tangle_shape_shifting_recipe_with_type_abbreviation)
+# shape-shifting recipe
+def foo a:_elem [
+  local-scope
+  load-ingredients
+  <label1>
+]
+# tangle some code that refers to the type ingredient
+after <label1> [
+  b:bool <- copy 0  # type abbreviation
+]
+# trigger specialization
+def main [
+  local-scope
+  foo 34
+]
+$error: 0
+
 :(scenario shape_shifting_recipe_coexists_with_primitive)
 # recipe overloading a primitive with a generic type
 def add a:&:foo:_elem [
diff --git a/075channel.mu b/075channel.mu
index 6aae8b87..ebac99a6 100644
--- a/075channel.mu
+++ b/075channel.mu
@@ -323,11 +323,11 @@ def close x:&:sink:_elem -> x:&:sink:_elem [
 #   future reads continue until the channel empties,
 #   then the channel is also closed for reading
 after <channel-write-initial> [
-  closed?:boolean <- get *chan, closed?:offset
+  closed?:bool <- get *chan, closed?:offset
   return-if closed?
 ]
 after <channel-read-empty> [
-  closed?:boolean <- get *chan, closed?:offset
+  closed?:bool <- get *chan, closed?:offset
   {
     break-unless closed?
     empty-result:&:_elem <- new _elem:type