3245 - refuse to run programs with errors

I started out incredibly lax about running past errors (I even used to
call them 'warnings' when I started Mu), but I've been gradually seeing
the wisdom of Go and Racket in refusing to run code if it doesn't pass
basic integrity checks (such as using a literal as an address).

Go is right to have no warnings, only errors. But where Go goes wrong is
in even caring about unused variables.

Racket and other languages perform more aggressive integrity checks so
that the can optimize more aggressively, and I'm starting to realize I
don't know enough to disagree with them.
This commit is contained in:
Kartik K. Agaram 2016-08-22 08:57:42 -07:00
parent 2d7131670e
commit 43781c7b69
2 changed files with 3 additions and 1 deletions

View File

@ -152,12 +152,13 @@ struct trace_stream {
trace_stream* Trace_stream = NULL;
int Trace_errors = 0; // used only when Trace_stream is NULL
// Top-level helper. IMPORTANT: can't nest
#define trace(...) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__)
// Errors are a special layer.
#define raise (!Trace_stream ? (tb_shutdown(),cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error"))
#define raise (!Trace_stream ? (tb_shutdown(),++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error"))
// Inside tests, fail any tests that displayed (unexpected) errors.
// Expected errors in tests should always be hidden and silently checked for.
:(before "End Test Teardown")

View File

@ -162,6 +162,7 @@ if (argc > 1) {
transform_all();
//? DUMP("");
//? exit(0);
if (Trace_errors) return 1;
save_snapshots();
//: Step 3: if we aren't running tests, locate a recipe called 'main' and