about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--057static_dispatch.cc1
-rw-r--r--059shape_shifting_recipe.cc27
2 files changed, 26 insertions, 2 deletions
diff --git a/057static_dispatch.cc b/057static_dispatch.cc
index 082452ff..54da5354 100644
--- a/057static_dispatch.cc
+++ b/057static_dispatch.cc
@@ -111,7 +111,6 @@ Transform.push_back(resolve_ambiguous_calls);  // idempotent
 :(code)
 void resolve_ambiguous_calls(recipe_ordinal r) {
   recipe& caller_recipe = get(Recipe, r);
-  if (!caller_recipe.has_header) return;
   trace(9991, "transform") << "--- resolve ambiguous calls for recipe " << caller_recipe.name << end();
   for (long long int index = 0; index < SIZE(caller_recipe.steps); ++index) {
     instruction& inst = caller_recipe.steps.at(index);
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc
index e308be3a..bc63d616 100644
--- a/059shape_shifting_recipe.cc
+++ b/059shape_shifting_recipe.cc
@@ -20,11 +20,20 @@ recipe foo a:_t -> result:_t [
 +mem: storing 14 in location 11
 +mem: storing 15 in location 12
 
-//: Before anything else, disable transforms for shape-shifting recipes.
+//: Before anything else, disable transforms for shape-shifting recipes and
+//: make sure we never try to actually run a shape-shifting recipe. We should
+//: be rewriting such instructions to *specializations* with the type
+//: ingredients filled in.
 
 :(before "End Transform Checks")
 if (any_type_ingredient_in_header(/*recipe_ordinal*/p->first)) continue;
 
+:(after "Running One Instruction")
+if (Current_routine->calls.front().running_step_index == 0
+    && any_type_ingredient_in_header(Current_routine->calls.front().running_recipe)) {
+  raise_error << "ran into unspecialized shape-shifting recipe " << current_recipe_name() << '\n' << end();
+}
+
 //: We'll be creating recipes without loading them from anywhere by
 //: *specializing* existing recipes, so make sure we don't clear any of those
 //: when we start running tests.
@@ -442,3 +451,19 @@ recipe foo a:_t -> b:_t [
   b <- copy a
 ]
 +error: main: no call found for 'b:address:number <- foo a'
+
+:(scenario specialize_inside_recipe_without_header)
+recipe main [
+  foo 3
+]
+recipe foo [
+  local-scope
+  x:number <- next-ingredient  # ensure no header
+  1:number/raw <- bar x  # call a shape-shifting recipe
+]
+recipe bar x:_elem -> y:_elem [
+  local-scope
+  load-ingredients
+  y <- add x, 1
+]
++mem: storing 4 in location 1