From 35eed621602544429b12818ab1da62b6097fd48e Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Fri, 3 Jun 2022 13:36:56 +0900 Subject: [PATCH] the top-level of a macro expansion should preserve the call site source (issue #835) --- eval.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eval.c b/eval.c index 017abf6f..871b72ef 100644 --- a/eval.c +++ b/eval.c @@ -776,8 +776,12 @@ static sexp analyze_macro_once (sexp ctx, sexp x, sexp op, int depth) { res = sexp_exceptionp(tmp) ? tmp : sexp_make_child_context(ctx, sexp_context_lambda(ctx)); if (!sexp_exceptionp(res) && !sexp_exceptionp(sexp_context_exception(ctx))) res = sexp_apply(res, sexp_macro_proc(op), tmp); - if (sexp_exceptionp(res) && sexp_not(sexp_exception_source(x))) - sexp_exception_source(res) = sexp_pair_source(sexp_car(tmp)); + if (sexp_pairp(sexp_car(tmp)) && sexp_pair_source(sexp_car(tmp))) { + if (sexp_pairp(res)) + sexp_pair_source(res) = sexp_pair_source(sexp_car(tmp)); + else if (sexp_exceptionp(res) && sexp_not(sexp_exception_source(x))) + sexp_exception_source(res) = sexp_pair_source(sexp_car(tmp)); + } sexp_gc_release1(ctx); return res; }