summaryrefslogtreecommitdiffstats
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
commitf7bfc3eda216ca57db65d8a5131be81a9f7ab361 (patch)
tree7b5176d8ecd14df2465c39ffcce61e3dfd7ea774
parent6781d0114f21a53e1a899fc2efe2959e2df72edc (diff)
downloadtxr-f7bfc3eda216ca57db65d8a5131be81a9f7ab361.tar.gz
txr-f7bfc3eda216ca57db65d8a5131be81a9f7ab361.tar.bz2
txr-f7bfc3eda216ca57db65d8a5131be81a9f7ab361.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.
-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);