about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--030container.cc6
-rw-r--r--042name.cc2
-rw-r--r--081run_interactive.cc11
-rw-r--r--edit.mu40
4 files changed, 55 insertions, 4 deletions
diff --git a/030container.cc b/030container.cc
index f90e92ba..c49aa877 100644
--- a/030container.cc
+++ b/030container.cc
@@ -107,8 +107,10 @@ case GET: {
   reagent base = current_instruction().ingredients.at(0);
   long long int base_address = base.value;
   type_ordinal base_type = base.types.at(0);
-  if (Type[base_type].kind != container)
-    raise << "'get' on a non-container in " << current_recipe_name () << ": " << current_instruction().to_string() << '\n' << die();
+  if (Type[base_type].kind != container) {
+    raise << current_recipe_name () << ": 'get' on a non-container " << base.original_string << '\n';
+    break;
+  }
   assert(is_literal(current_instruction().ingredients.at(1)));
   assert(scalar(ingredients.at(1)));
   long long int offset = ingredients.at(1).at(0);
diff --git a/042name.cc b/042name.cc
index ccf4a353..d2a18b33 100644
--- a/042name.cc
+++ b/042name.cc
@@ -112,7 +112,7 @@ int find_element_name(const type_ordinal t, const string& name) {
   for (long long int i = 0; i < SIZE(container.element_names); ++i) {
     if (container.element_names.at(i) == name) return i;
   }
-  raise << "unknown element " << name << " in container " << Type[t].name << '\n' << die();
+  raise << "unknown element " << name << " in container " << Type[t].name << '\n';
   return -1;
 }
 
diff --git a/081run_interactive.cc b/081run_interactive.cc
index 5258b2c0..f7d049ff 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -188,6 +188,7 @@ if (must_clean_up_interactive) clean_up_interactive();
 if (must_clean_up_interactive) clean_up_interactive();
 :(code)
 void clean_up_interactive() {
+  Trace_stream->newline();  // flush trace
   Hide_warnings = false;
   Running_interactive = false;
   // hack: assume collect_layer isn't set anywhere else
@@ -267,13 +268,23 @@ Recipe_ordinal["reload"] = RELOAD;
 :(before "End Primitive Recipe Implementations")
 case RELOAD: {
   assert(scalar(ingredients.at(0)));
+  if (!Trace_stream) {
+    Trace_file = "";  // if there wasn't already a stream we don't want to save it
+    Trace_stream = new trace_stream;
+    Trace_stream->collect_layer = "warn";
+  }
   Loading_interactive = true;
   Hide_warnings = true;
   load(read_mu_string(ingredients.at(0).at(0)));
   transform_all();
+  Trace_stream->newline();  // flush trace
   Hide_warnings = false;
   Loading_interactive = false;
   products.resize(1);
   products.at(0).push_back(warnings_from_trace());
+  if (Trace_stream->collect_layer == "warn") {
+    delete Trace_stream;
+    Trace_stream = NULL;
+  }
   break;
 }
diff --git a/edit.mu b/edit.mu
index f47553ab..9df63886 100644
--- a/edit.mu
+++ b/edit.mu
@@ -655,7 +655,7 @@ recipe event-loop [
         do-run?:boolean <- equal k:address:number/deref, 65526:literal/F10
         break-unless do-run?:boolean
         run-sandboxes env:address:programming-environment-data
-        screen:address <- render-sandbox-side screen:address, env:address:programming-environment-data
+        screen:address <- render-all screen:address, env:address:programming-environment-data
         # F10 doesn't mess with the recipe side
         update-cursor screen:address, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:address:boolean/deref
         show-screen screen:address
@@ -3165,6 +3165,44 @@ scenario editor-provides-edited-contents [
   ]
 ]
 
+## handling malformed programs
+
+scenario run-shows-warnings-in-get [
+  $close-trace
+  assume-screen 100:literal/width, 15:literal/height
+  assume-console [
+    press 65526  # F10
+  ]
+  run [
+    x:address:array:character <- new [ 
+recipe foo2 [
+  get 123:number, foo:offset
+]]
+    y:address:array:character <- new [foo2]
+    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 foo2 [                                     ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  get 123:number, foo:offset                      ┊                                                x.
+    .]                                                 ┊foo2                                             .
+    .unknown element foo in container number           ┊foo2: 'get' on a non-container 123:number        .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                 .
+  ]
+  screen-should-contain-in-color 1:literal/red, [
+    .                                                                                                    .
+    .                                                                                                    .
+    .                                                                                                    .
+    .                                                                                                    .
+    .                                                                                                    .
+    .unknown element foo in container number            foo2: 'get' on a non-container 123:number        .
+    .                                                                                                    .
+  ]
+]
+
 ## helpers for drawing editor borders
 
 recipe draw-box [