summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-04 19:42:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-11-04 19:42:28 -0700
commit47f573090ad0b52200ef0359282410977e789761 (patch)
tree7b5176d8ecd14df2465c39ffcce61e3dfd7ea774 /eval.c
parent7ccd643ac222d3da563b386cef5caf7af1b79363 (diff)
downloadtxr-47f573090ad0b52200ef0359282410977e789761.tar.gz
txr-47f573090ad0b52200ef0359282410977e789761.tar.bz2
txr-47f573090ad0b52200ef0359282410977e789761.zip
Show location of expanded form in exp-time errors.
Old behavior: | 1> (sys:expand '(defstruct foo bar)) | ** defstruct: inheritance base bar does | not name a struct type | ** during expansion at | /usr/local/share/txr/stdlib/struct.tl:120 | of form (defstruct foo bar) New behavior: | 1> (sys:expand '(defstruct foo bar)) | ** defstruct: inheritance base bar does | not name a struct type | ** during expansion at expr-1:1 of form (defstruct foo | bar) | ** by macro code located at | /home/kaz/txr/share/txr/stdlib/struct.tl:120 * eval.c (error_trace): Show location of the form being expanded in the "during expansion" message, rather than, confusingly, the locaton of the code of its macro. Then, if the location of the macro is available, show that in a separate message whose wording makes it clear that the location of the expanding macro is being given.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index b1c84794..a1c8c631 100644
--- a/eval.c
+++ b/eval.c
@@ -297,12 +297,19 @@ void error_trace(val exsym, val exvals, val out_stream, val prefix)
}
if (last_form_expanded) {
- uses_or2;
val ex_info = source_loc_str(last_form_expanded, nil);
val form = last_form_expanded;
- format(out_stream, lit("~a during expansion at ~a of form ~!~s\n"),
- prefix, or2(info, ex_info), last_form_expanded, nao);
+ if (ex_info)
+ format(out_stream, lit("~a during expansion at ~a of form ~!~s\n"),
+ prefix, ex_info, last_form_expanded, nao);
+ else
+ format(out_stream, lit("~a during expansion of form ~!~s\n"),
+ prefix, last_form_expanded, nao);
+
+ if (info)
+ format(out_stream, lit("~a by macro code located at ~a\n"), prefix,
+ info, nao);
for (;;) {
val origin = lookup_origin(form);