about summary refs log tree commit diff stats
path: root/036call_reply.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-10 02:00:49 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-10 02:04:50 -0700
commit7402ce32ee0cd3301677d0037718b175868a56a8 (patch)
treeefe29f138b11d4029846e27113e0fa06b9e0a3f6 /036call_reply.cc
parent19323e7afc4b6c4da04c62ecaf05eb3768cacd93 (diff)
downloadmu-7402ce32ee0cd3301677d0037718b175868a56a8.tar.gz
1745 - hoist warning/response strings out of editor-data
Still ugly as hell. Some tests failing, but they're most likely
wrong. We need to test cursor positioning at the level of the
environment and take it away from the responsibilities of individual
editors. Also bring back the line at the bottom of each editor.

The non-test run ('main' in edit.mu) is completely borked. Sluggish as
hell, and I can't seem to switch focus to the sandbox editor.
Diffstat (limited to '036call_reply.cc')
-rw-r--r--036call_reply.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/036call_reply.cc b/036call_reply.cc
index 71aa4991..54866765 100644
--- a/036call_reply.cc
+++ b/036call_reply.cc
@@ -41,7 +41,11 @@ case REPLY: {
       vector<string> tmp = property(reply_inst.ingredients.at(i), "same-as-ingredient");
       assert(SIZE(tmp) == 1);
       long long int ingredient_index = to_integer(tmp.at(0));
-      if (caller_instruction.products.at(i).value != caller_instruction.ingredients.at(ingredient_index).value)
+      if (ingredient_index >= SIZE(caller_instruction.ingredients))
+        raise << current_recipe_name() << ": 'same-as-ingredient' metadata overflows ingredients in: " << caller_instruction.to_string() << '\n';
+//?       cerr << caller_instruction.products.size() << ' ' << i << ' ' << caller_instruction.ingredients.size() << ' ' << ingredient_index << '\n'; //? 1
+//?       cerr << caller_instruction.to_string() << '\n'; //? 1
+      if (!is_dummy(caller_instruction.products.at(i)) && caller_instruction.products.at(i).value != caller_instruction.ingredients.at(ingredient_index).value)
         raise << current_recipe_name() << ": 'same-as-ingredient' result " << caller_instruction.products.at(i).value << " from call to " << callee << " must be location " << caller_instruction.ingredients.at(ingredient_index).value << '\n';
     }
   }
@@ -79,6 +83,18 @@ recipe test1 [
 ]
 +warn: main: 'same-as-ingredient' result 2 from call to test1 must be location 1
 
+:(scenario reply_same_as_ingredient_dummy)
+% Hide_warnings = true;
+recipe main [
+  1:number <- copy 0:literal
+  _ <- test1 1:number  # call with different ingredient and product
+]
+recipe test1 [
+  10:address:number <- next-ingredient
+  reply 10:address:number/same-as-ingredient:0
+]
+$warn: 0
+
 :(code)
 string to_string(const vector<double>& in) {
   if (in.empty()) return "[]";