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.
This commit is contained in:
parent
efc5c08130
commit
4efc0ff316
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
40
edit.mu
40
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 [
|
||||
|
|
Loading…
Reference in New Issue
Block a user