From 28c987e2693c436d0edd65fe1f6a9e08dcb97359 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 25 Oct 2021 07:54:39 -0700 Subject: repl: bugfix: half-baked source auto loading in completion. The following behavior is observed. When we clean the compiled files using "make clean-tlo", then autoloading during completion does not work reliably for some symbols like dissassemble and compile. The symbols don't complete, and afterward, the functions remain undefined, and no longer autoload. The root cause is that when some modules are loaded form source, deferred warnings occur, due to code referring to symbols that are defined later. But the provide_completions function installs a catch for all exceptions, including deferred warnings. It thereby abruptly terminates loads which trigger deferred warnings, leaving them half-complete. The fix is to catch only errors. * parser.c (catch_error): New global variable. (load_rcfile): Use catch_error from now on instead of locally consing this. (provide_completions): Use catch_error instead of catch_all. (parse_init): gc-protect catch_error and initialize it. --- parser.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/parser.c b/parser.c index 3a14d4ed..060643b4 100644 --- a/parser.c +++ b/parser.c @@ -80,7 +80,7 @@ struct cobj_class *parser_cls; static lino_t *lino_ctx; static int repl_level = 0; -static val stream_parser_hash, catch_all; +static val stream_parser_hash, catch_all, catch_error; static void yy_tok_mark(struct yy_token *tok) { @@ -888,10 +888,9 @@ static void load_rcfile(val name) val resolved_name; val lisp_p = t; val stream = nil; - val catch_syms = cons(error_s, nil); val path_private_to_me_p = intern(lit("path-private-to-me-p"), user_package); - uw_catch_begin (catch_syms, sy, va); + uw_catch_begin (catch_error, sy, va); open_txr_file(name, &lisp_p, &resolved_name, &stream, self); @@ -1028,7 +1027,7 @@ static void provide_completions(const wchar_t *data, (void) ctx; - uw_catch_begin (catch_all, exsym, exvals); + uw_catch_begin (catch_error, exsym, exvals); if (!ptr) goto out; @@ -1898,9 +1897,11 @@ void parse_init(void) parser_cls = cobj_register(parser_s); - protect(&stream_parser_hash, &unique_s, &catch_all, convert(val *, 0)); + protect(&stream_parser_hash, &unique_s, + &catch_all, &catch_error, convert(val *, 0)); stream_parser_hash = make_hash(hash_weak_and, nil); catch_all = cons(t, nil); + catch_error = cons(error_s, nil); parser_l_init(); -- cgit v1.2.3