summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-13 19:24:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-13 19:24:31 -0700
commitb95fa78d3bf572b190cb26bfc73a35d28a30d0dd (patch)
treeaa73bedc8fe8ac0417de536bedfe28647a6c96cc
parenta9e4ee0f8d63dbdae72cdfa31ef16276ed251060 (diff)
downloadtxr-b95fa78d3bf572b190cb26bfc73a35d28a30d0dd.tar.gz
txr-b95fa78d3bf572b190cb26bfc73a35d28a30d0dd.tar.bz2
txr-b95fa78d3bf572b190cb26bfc73a35d28a30d0dd.zip
bugfix: definitions must trigger autoload.
When a function, macro, variale, symbol macro or struct is being defined, we must trigger any auto-load for that symbol. If the definition is redefining a library symbol, then if the autoload is later triggered, it will surprisingly reinstate the library definition. * eval.c (rt_defvarl, op_defsymacro, rt_defsymacro, rt_defun, rt_defmacro): Insert calls to lisplib_try_load against the symbol being defined. * struct.c (make_struct_type): Likewise.
-rw-r--r--eval.c7
-rw-r--r--struct.c2
2 files changed, 8 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index b2954e91..b7cc387d 100644
--- a/eval.c
+++ b/eval.c
@@ -1945,7 +1945,8 @@ static val rt_defvarl(val sym)
{
val self = lit("defvar");
val new_p;
- val cell = gethash_c(self, top_vb, sym, mkcloc(new_p));
+ val cell = (lisplib_try_load(sym),
+ gethash_c(self, top_vb, sym, mkcloc(new_p)));
if (new_p || !cdr(cell)) {
uw_purge_deferred_warning(cons(var_s, sym));
@@ -1978,6 +1979,7 @@ static val op_defsymacro(val form, val env)
(void) env;
+ lisplib_try_load(sym);
remhash(top_vb, sym);
if (!opt_compat || opt_compat > 143)
remhash(special, sym);
@@ -1987,6 +1989,7 @@ static val op_defsymacro(val form, val env)
static val rt_defsymacro(val sym, val def)
{
+ lisplib_try_load(sym);
remhash(top_vb, sym);
remhash(special, sym);
sethash(top_smb, sym, cons(sym, def));
@@ -2008,6 +2011,7 @@ void trace_check(val name)
static val rt_defun(val name, val function)
{
+ lisplib_try_load(name);
sethash(top_fb, name, cons(name, function));
uw_purge_deferred_warning(cons(fun_s, name));
uw_purge_deferred_warning(cons(sym_s, name));
@@ -2016,6 +2020,7 @@ static val rt_defun(val name, val function)
static val rt_defmacro(val sym, val name, val function)
{
+ lisplib_try_load(sym);
sethash(top_mb, sym, cons(name, function));
return name;
}
diff --git a/struct.c b/struct.c
index a00345fa..ccdb939f 100644
--- a/struct.c
+++ b/struct.c
@@ -352,6 +352,8 @@ val make_struct_type(val name, val supers,
val self = lit("make-struct-type");
val iter;
+ lisplib_try_load(name);
+
if (!listp(supers))
supers = cons(supers, nil);