From ab1059ae34e48d37d0c5702c3bd5e3bf2afb1a20 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 20 Apr 2019 16:46:51 -0700 Subject: defun: record source loc info. The interpreted defun should tag the function form that is obtainable with func-get-form with source location info. * eval.c (op_defun): In all cases, propagate source loc info from the form to the function form that is bound to the function name. (op_defmacro): Propagate the source location info in the same manner: not from the body (which could be empty) but from the form. --- eval.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eval.c b/eval.c index 518730fd..bf575c9c 100644 --- a/eval.c +++ b/eval.c @@ -1990,14 +1990,14 @@ static val op_defun(val form, val env) if (!consp(name)) { val block = cons(block_s, cons(name, body)); - val fun = cons(name, cons(params, cons(block, nil))); + val fun = rlcp(cons(name, cons(params, cons(block, nil))), form); return rt_defun(name, func_interp(env, fun)); } else if (car(name) == meth_s) { val binding = lookup_fun(nil, intern(lit("define-method"), system_package)); val type_sym = second(name); val meth_name = third(name); val block = cons(block_s, cons(meth_name, body)); - val fun = cons(meth_name, cons(params, cons(block, nil))); + val fun = rlcp(cons(meth_name, cons(params, cons(block, nil))), form); bug_unless (binding); @@ -2005,7 +2005,7 @@ static val op_defun(val form, val env) } else if (car(name) == macro_s) { val sym = cadr(name); val block = cons(block_s, cons(sym, body)); - val fun = cons(name, cons(params, cons(block, nil))); + val fun = rlcp(cons(name, cons(params, cons(block, nil))), form); if (!bindable(sym)) eval_error(form, lit("defun: ~s isn't a bindable symbol in ~s"), @@ -2043,7 +2043,7 @@ static val op_defmacro(val form, val env) val name = first(args); val params = second(args); val body = rest(rest(args)); - val block = rlcp(cons(block_s, cons(name, body)), body); + val block = rlcp(cons(block_s, cons(name, body)), form); if (gethash(op_table, name)) eval_error(form, lit("defmacro: ~s is a special operator"), name, nao); -- cgit v1.2.3