From 93d4cc937ee480952cb93f21e5a04a96296c8302 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 10 Nov 2016 21:39:02 -0800 Subject: 3663 - fix a refcounting bug: '(type)' != 'type' This was a large commit, and most of it is a follow-up to commit 3309, undoing what is probably the final ill-considered optimization I added to s-expressions in Mu: I was always representing (a b c) as (a b . c), etc. That is now gone. Why did I need to take it out? The key problem was the error silently ignored in layer 30. That was causing size_of("(type)") to silently return garbage rather than loudly complain (assuming 'type' was a simple type). But to take it out I had to modify types_strictly_match (layer 21) to actually strictly match and not just do a prefix match. In the process of removing the prefix match, I had to make extracting recipe types from recipe headers more robust. So far it only matched the first element of each ingredient's type; these matched: (recipe address:number -> address:number) (recipe address -> address) I didn't notice because the dotted notation optimization was actually representing this as: (recipe address:number -> address number) --- One final little thing in this commit: I added an alias for 'assert' called 'assert_for_now', to indicate that I'm not sure something's really an invariant, that it might be triggered by (invalid) user programs, and so require more thought on error handling down the road. But this may well be an ill-posed distinction. It may be overwhelmingly uneconomic to continually distinguish between model invariants and error states for input. I'm starting to grow sympathetic to Google Analytics's recent approach of just banning assertions altogether. We'll see.. --- 003trace.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to '003trace.cc') diff --git a/003trace.cc b/003trace.cc index c4344f2c..aa519eb1 100644 --- a/003trace.cc +++ b/003trace.cc @@ -176,6 +176,9 @@ int Trace_errors = 0; // used only when Trace_stream is NULL // Errors are a special layer. #define raise (!Trace_stream ? (tb_shutdown(),++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error")) +// If we aren't yet sure how to deal with some corner case, use assert_for_now +// to indicate that it isn't an inviolable invariant. +#define assert_for_now assert // Inside tests, fail any tests that displayed (unexpected) errors. // Expected errors in tests should always be hidden and silently checked for. -- cgit 1.4.1-2-gfad0