about summary refs log tree commit diff stats
path: root/003trace.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-22 08:57:42 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-22 08:59:04 -0700
commit43781c7b694030078aa00c69668ed06a0c911624 (patch)
treefe01009f2ee9bc32172f2c8319c34b2f8adae413 /003trace.cc
parent2d7131670e771af8bac13c315ba262cb3a321505 (diff)
downloadmu-43781c7b694030078aa00c69668ed06a0c911624.tar.gz
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.
Diffstat (limited to '003trace.cc')
-rw-r--r--003trace.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/003trace.cc b/003trace.cc
index 10bdca1c..bd6892a2 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -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")