summaryrefslogtreecommitdiffstats
path: root/unwind.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-26 19:46:18 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-11-26 19:46:18 -0800
commit54256c89eec80c2a909416dc86c1cc9e0ed0c046 (patch)
treedd76b6320af000965982dbf9d6a8dc7a609812fa /unwind.c
parent30b30d178a59ba42182d707061b86bb7580ebeb6 (diff)
downloadtxr-54256c89eec80c2a909416dc86c1cc9e0ed0c046.tar.gz
txr-54256c89eec80c2a909416dc86c1cc9e0ed0c046.tar.bz2
txr-54256c89eec80c2a909416dc86c1cc9e0ed0c046.zip
Expander warns about unbound variables.
* eval.c (eval_exception): New static function. (eval_error): Reduced to wrapper around eval_exception. (eval_warn): New function. (me_op): Bind the rest symbol in a shadowing env to suppress watnings about unbound rest. (do_expand): Throw a warning when a bindable symbol is traversed that has no binding. (expand): Don't install atoms as last_form_expanded. * lib.c (warning_s, restart_s, continue_s): New symbol variables. (obj_init): Initialize new symbol variables. * lib.h (warning_s, restart_s, continue_s): Declared. * lisplib.c (except_set_entries): New entries for ignwarn and macro-time-ignwarn. * parser.c (repl_warning): New static function. (repl): Use repl_warning function as a handler for warning exceptions: to print their message and then continue by throwing a continue exception. * parser.y (warning_continue): New static function. (parse_once): Use warning_continue to ignore warnings. In other words, we suppress warnings from Lisp that is mixed into TXR pattern language code, because this produces too many false positives. * share/txr/stdlib/except.tl (ignwarn, macro-time-ignwarn): New macros. * share/txr/stdlib/place.tl (call-update-expander, call-clobber-expander, call-delete-expander): Ignore warnings around calls to sys:expand, because of some gensym-related false positives (we expand code into which we inserted some gensyms, without having inserted the constructs which bind them. * tests/011/macros-2.txr: Suppress unbound variable warnings from a test case. * tests/012/ifa.tl: Bind unbound x y variables in one test case. * tests/012/struct.tl: Suppress unbound variable warnings in some test cases. * uwind.c (uw_throw): If a warning is unhandled, then print its message with a "warning" prefix and then throw a continue exception. (uw_register_subtype): Eliminate the check for sub already being a subtype of sup. This allows us to officially register new types against t. (uw_late_init): Register continue exception type as a subtype of the restart type. Formally register warning type. * txr.1: Documented ignwarn.
Diffstat (limited to 'unwind.c')
-rw-r--r--unwind.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/unwind.c b/unwind.c
index a79a69bd..a993e7cf 100644
--- a/unwind.c
+++ b/unwind.c
@@ -556,6 +556,13 @@ val uw_throw(val sym, val args)
abort();
}
+ if (sym == warning_s) {
+ --reentry_count;
+ format(std_error, lit("warning: ~a\n"), car(args), nao);
+ uw_throw(continue_s, nil);
+ abort();
+ }
+
{
loc pfun = lookup_var_l(nil, unhandled_hook_s);
val fun = deref(pfun);
@@ -667,10 +674,6 @@ val uw_register_subtype(val sub, val sup)
sub, sup, nao);
}
- if (uw_exception_subtype_p(sub, sup))
- uw_throwf(type_error_s, lit("~s is already an exception subtype of ~s"),
- sub, sup, nao);
-
if (uw_exception_subtype_p(sup, sub))
uw_throwf(type_error_s, lit("~s is already an exception supertype of ~s"),
sub, sup, nao);
@@ -975,4 +978,6 @@ void uw_late_init(void)
func_n2v(uw_invoke_catch));
reg_fun(sys_capture_cont_s = intern(lit("capture-cont"), system_package),
func_n3o(uw_capture_cont, 2));
+ uw_register_subtype(continue_s, restart_s);
+ uw_register_subtype(warning_s, t);
}