diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-04 19:42:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-04 19:42:28 -0700 |
commit | 47f573090ad0b52200ef0359282410977e789761 (patch) | |
tree | 7b5176d8ecd14df2465c39ffcce61e3dfd7ea774 /eval.c | |
parent | 7ccd643ac222d3da563b386cef5caf7af1b79363 (diff) | |
download | txr-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.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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); |