diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-21 23:38:21 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-21 23:38:21 -0700 |
commit | 4efc0ff3168f9ff6e80b2fa4b3302baac4035abb (patch) | |
tree | 83843682dfa136f08f7a3603902d39f8b76c10b5 | |
parent | efc5c081304f7da0d8ffcc863f14922845d04295 (diff) | |
download | mu-4efc0ff3168f9ff6e80b2fa4b3302baac4035abb.tar.gz |
1826 - edit: start carefully showing all errors
Eventually we might be able to get rid of die entirely. This is just a preliminary stab at a random error. In the process I ran into two issues that have impeded debugging before: a) Naming conflicts within scenarios are a real no-no. I need to warn on them, but the rules are getting complicated: Always print warnings on redefine But not in interactive mode Or in scenarios checking warning behavior Unless the scenario recipe itself is overridden b) Now that we've added collect_layers and a long time can go between traces, debugging is a minefield because trace lines don't print to screen immediately after they're created. Need to do something about that. Maybe explicitly trigger collection by tracing '\n' or something. These are the next two items on my todo list.
-rw-r--r-- | 030container.cc | 6 | ||||
-rw-r--r-- | 042name.cc | 2 | ||||
-rw-r--r-- | 081run_interactive.cc | 11 | ||||
-rw-r--r-- | edit.mu | 40 |
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 [ |