about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-23 21:48:06 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-23 21:48:06 -0700
commit235958e8b9c29e1bb4138e912d443daeaae5afcb (patch)
tree6731285466836938950cdcc619f846e7def6095e
parente993c19b249dbc9f3edaff4b24078a00c493b3d2 (diff)
downloadmu-235958e8b9c29e1bb4138e912d443daeaae5afcb.tar.gz
1829
-rw-r--r--037recipe.cc2
-rw-r--r--042name.cc14
-rw-r--r--edit.mu29
3 files changed, 38 insertions, 7 deletions
diff --git a/037recipe.cc b/037recipe.cc
index 5a4acb82..95e61073 100644
--- a/037recipe.cc
+++ b/037recipe.cc
@@ -32,7 +32,7 @@ type_ordinal recipe_ordinal = Type_ordinal["recipe-ordinal"] = Next_type_ordinal
 Type[recipe_ordinal].name = "recipe-ordinal";
 
 :(before "End Reagent-parsing Exceptions")
-if (r.properties.at(0).second.at(0) == "recipe") {
+if (!r.properties.at(0).second.empty() && r.properties.at(0).second.at(0) == "recipe") {
   r.set_value(Recipe_ordinal[r.name]);
   return;
 }
diff --git a/042name.cc b/042name.cc
index d2a18b33..fe3c43a7 100644
--- a/042name.cc
+++ b/042name.cc
@@ -43,7 +43,7 @@ void transform_names(const recipe_ordinal r) {
       check_metadata(metadata, inst.ingredients.at(in), r);
       if (is_numeric_location(inst.ingredients.at(in))) numeric_locations_used = true;
       if (is_named_location(inst.ingredients.at(in))) names_used = true;
-      if (disqualified(inst.ingredients.at(in))) continue;
+      if (disqualified(inst.ingredients.at(in), inst)) continue;
       if (!already_transformed(inst.ingredients.at(in), names)) {
         raise << "use before set: " << inst.ingredients.at(in).name << " in " << Recipe[r].name << '\n';
       }
@@ -53,7 +53,7 @@ void transform_names(const recipe_ordinal r) {
       check_metadata(metadata, inst.products.at(out), r);
       if (is_numeric_location(inst.products.at(out))) numeric_locations_used = true;
       if (is_named_location(inst.products.at(out))) names_used = true;
-      if (disqualified(inst.products.at(out))) continue;
+      if (disqualified(inst.products.at(out), inst)) continue;
       if (names.find(inst.products.at(out).name) == names.end()) {
         trace("name") << "assign " << inst.products.at(out).name << " " << curr_idx;
         names[inst.products.at(out).name] = curr_idx;
@@ -71,17 +71,19 @@ void check_metadata(map<string, vector<type_ordinal> >& metadata, const reagent&
   if (is_raw(x)) return;
   // if you use raw locations you're probably doing something unsafe
   if (is_integer(x.name)) return;
+  if (x.types.empty()) return;  // will throw a more precise warning elsewhere
   if (metadata.find(x.name) == metadata.end())
     metadata[x.name] = x.types;
   if (metadata[x.name] != x.types)
     raise << x.name << " used with multiple types in " << Recipe[r].name << '\n';
 }
 
-bool disqualified(/*mutable*/ reagent& x) {
+bool disqualified(/*mutable*/ reagent& x, const instruction& inst) {
 //?   cerr << x.to_string() << '\n'; //? 1
-  if (x.types.empty())
-    raise << "missing type in " << x.to_string() << '\n';
-  assert(!x.types.empty());
+  if (x.types.empty()) {
+    raise << "missing type in '" << inst.to_string() << "'\n";
+    return true;
+  }
   if (is_raw(x)) return true;
   if (is_literal(x)) return true;
   if (is_integer(x.name)) return true;
diff --git a/edit.mu b/edit.mu
index 040cd270..b0d0d895 100644
--- a/edit.mu
+++ b/edit.mu
@@ -3203,6 +3203,35 @@ recipe foo [
   ]
 ]
 
+scenario run-shows-missing-type-warnings [
+  $close-trace
+  assume-screen 100:literal/width, 15:literal/height
+  assume-console [
+    press 65526  # F10
+  ]
+  run [
+    x:address:array:character <- new [ 
+recipe foo [
+  x:number <- copy 0
+  copy x
+]]
+    y:address:array:character <- new []
+    env:address:programming-environment-data <- new-programming-environment screen:address, x:address:array:character, y:address:array:character
+    event-loop screen:address, console:address, env:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .                                                                                 run (F10)          .
+    .                                                  ┊                                                 .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x:number <- copy 0                              ┊                                                 .
+    .  copy x                                          ┊                                                 .
+    .]                                                 ┊                                                 .
+    .missing type in 'copy x'                          ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]
+
 ## helpers for drawing editor borders
 
 recipe draw-box [