about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-18 11:30:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-18 11:35:24 -0800
commit322ce34d77b4e2d8c6d721b156c02496d105741f (patch)
tree29e4556b502d24380126a1503203289d2293b8d0
parent5967e82fab9feea381dd1b6e1925177e771d86dc (diff)
downloadmu-322ce34d77b4e2d8c6d721b156c02496d105741f.tar.gz
2458 - edit/: recipe side free of sandbox errors
This is happening because of our recent generic changes, which trigger
some post-processing transforms on all recipes even if we processed them
before. We could clear 'interactive' inside 'reload' to avoid this, but
random 'run' blocks in scenarios can still pick up errors from sandboxes
earlier in a scenario. The right place to clear the 'interactive' recipe
is right after we use it, in run_code_end().
-rw-r--r--012transform.cc1
-rw-r--r--050scenario.cc4
-rw-r--r--091run_interactive.cc10
-rw-r--r--edit/010-warnings.mu35
4 files changed, 48 insertions, 2 deletions
diff --git a/012transform.cc b/012transform.cc
index 7837ae67..ad0d2b73 100644
--- a/012transform.cc
+++ b/012transform.cc
@@ -42,6 +42,7 @@ void transform_all() {
       r.transformed_until = t;
     }
   }
+//?   cerr << "wrapping up transform\n";
   parse_int_reagents();  // do this after all other transforms have run
   // End Transform All
 }
diff --git a/050scenario.cc b/050scenario.cc
index 71dfa72d..9f4c5c86 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -197,9 +197,13 @@ case RUN: {
 case RUN: {
   ostringstream tmp;
   tmp << "recipe run" << Next_recipe_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]";
+//?   cerr << "before load\n";
   vector<recipe_ordinal> tmp_recipe = load(tmp.str());
+//?   cerr << "before bind\n";
   bind_special_scenario_names(tmp_recipe.at(0));
+//?   cerr << "before transform\n";
   transform_all();
+//?   cerr << "end\n";
   if (Trace_stream) {
     ++Trace_stream->callstack_depth;
     trace(9998, "trace") << "run: incrementing callstack depth to " << Trace_stream->callstack_depth << end();
diff --git a/091run_interactive.cc b/091run_interactive.cc
index 25e02836..a883a5ae 100644
--- a/091run_interactive.cc
+++ b/091run_interactive.cc
@@ -107,6 +107,7 @@ bool run_interactive(long long int address) {
 }
 
 void run_code_begin() {
+//?   cerr << "loading new trace\n";
   // stuff to undo later, in run_code_end()
   Hide_warnings = true;
   Hide_errors = true;
@@ -119,6 +120,7 @@ void run_code_begin() {
 }
 
 void run_code_end() {
+//?   cerr << "back to old trace\n";
   Hide_warnings = false;
   Hide_errors = false;
   Disable_redefine_warnings = false;
@@ -127,6 +129,7 @@ void run_code_end() {
   Save_trace_stream = NULL;
   Trace_file = Save_trace_file;
   Save_trace_file.clear();
+  Recipe.erase(get(Recipe_ordinal, "interactive"));  // keep past sandboxes from inserting errors
 }
 
 :(before "End Load Recipes")
@@ -417,6 +420,7 @@ case RELOAD: {
 }
 :(before "End Primitive Recipe Implementations")
 case RELOAD: {
+//?   cerr << "== reload\n";
   // clear any containers in advance
   for (long long int i = 0; i < SIZE(recently_added_types); ++i) {
     Type_ordinal.erase(get(Type, recently_added_types.at(i)).name);
@@ -427,15 +431,17 @@ case RELOAD: {
   routine* save_current_routine = Current_routine;
   Current_routine = NULL;
   vector<recipe_ordinal> recipes_reloaded = load(code);
-  for (long long int i = 0; i < SIZE(recipes_reloaded); ++i) {
+  // clear a few things from previous runs
+  // ad hoc list; we've probably missed a few
+  for (long long int i = 0; i < SIZE(recipes_reloaded); ++i)
     Name.erase(recipes_reloaded.at(i));
-  }
   transform_all();
   Trace_stream->newline();  // flush trace
   Current_routine = save_current_routine;
   products.resize(1);
   products.at(0).push_back(trace_error_warning_contents());
   run_code_end();  // wait until we're done with the trace contents
+//?   cerr << "reload done\n";
   break;
 }
 
diff --git a/edit/010-warnings.mu b/edit/010-warnings.mu
index 6e5eeace..b2d927c2 100644
--- a/edit/010-warnings.mu
+++ b/edit/010-warnings.mu
@@ -54,6 +54,7 @@ recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-d
   warnings:address:address:array:character <- get-address *sandbox, warnings:offset
   trace:address:address:array:character <- get-address *sandbox, trace:offset
   fake-screen:address:address:screen <- get-address *sandbox, screen:offset
+#?   $print [run-interactive], 10/newline
   *response, *warnings, *fake-screen, *trace, completed?:boolean <- run-interactive data
   {
     break-if *warnings
@@ -61,6 +62,7 @@ recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-d
     *warnings <- new [took too long!
 ]
   }
+#?   $print [done with run-interactive], 10/newline
 ]
 
 # make sure we render any trace
@@ -115,6 +117,39 @@ recipe foo [
   ]
 ]
 
+scenario run-hides-warnings-from-past-sandboxes [
+  trace-until 100/app  # trace too long
+  assume-screen 100/width, 15/height
+  1:address:array:character <- new []
+  2:address:array:character <- new [get foo, x:offset]  # invalid
+  3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
+  assume-console [
+    press F4  # generate error
+  ]
+  run [
+    event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
+  ]
+  assume-console [
+    left-click 3, 80
+    press ctrl-k
+    type [add 2, 2]  # valid code
+    press F4  # error should disappear
+  ]
+  run [
+    event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .                                                  ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                x.
+    .                                                  ┊add 2, 2                                         .
+    .                                                  ┊4                                                .
+    .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                 .
+  ]
+]
+
 scenario run-shows-missing-type-warnings [
   trace-until 100/app  # trace too long
   assume-screen 100/width, 15/height