summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-05-09 21:30:34 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-05-09 21:30:34 -0700
commite1952b2d9c4dc9165d05161e170b272a1d726be9 (patch)
treec01d60c3597199605d66db025fc21d312eaf1683 /stdlib
parente7d52c9b22f569c4c02d59c4c958f7750af2e264 (diff)
downloadtxr-e1952b2d9c4dc9165d05161e170b272a1d726be9.tar.gz
txr-e1952b2d9c4dc9165d05161e170b272a1d726be9.tar.bz2
txr-e1952b2d9c4dc9165d05161e170b272a1d726be9.zip
compiler: improvements in reporting form in diagnostics.
* eval.c (ctx_name): Do not report just the car of the form. If the form starts with three symbols, list those; if two, list those. * stdlib/compiler.tl (expand-defun): Set the defun form as the macro ancestor of the lambda, rather than propagating source location info. Then diagnostics that previously refer to a lambda will correctly refer to the defun and thank to the above change in eval.c, include its name. * stdlib/pmac.t (define-param-expander): A similar change here. We make the define-param-expander form the macro ancestor of the lambda, so that diagnostics agains tthe lambda will show that form.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/compiler.tl2
-rw-r--r--stdlib/pmac.tl14
2 files changed, 8 insertions, 8 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl
index b516d91a..349fd9ab 100644
--- a/stdlib/compiler.tl
+++ b/stdlib/compiler.tl
@@ -2145,7 +2145,7 @@
(defun expand-defun (form)
(mac-param-bind form (t name args . body) form
(flet ((mklambda (block-name block-sym)
- (rlcp ^(lambda ,args (,block-sym ,block-name ,*body)) form)))
+ (set-macro-ancestor ^(lambda ,args (,block-sym ,block-name ,*body)) form)))
(cond
((bindable name)
^(sys:rt-defun ',name ,(mklambda name 'sys:blk)))
diff --git a/stdlib/pmac.tl b/stdlib/pmac.tl
index d56e1fda..1f383e6f 100644
--- a/stdlib/pmac.tl
+++ b/stdlib/pmac.tl
@@ -25,14 +25,14 @@
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
;; POSSIBILITY OF SUCH DAMAGE.
-(defmacro define-param-expander (keyword
+(defmacro define-param-expander (:form f keyword
(parms body : (env (gensym)) (form (gensym)))
- . forms)
- ^(progn
- (set [*param-macro* ,keyword]
- (lambda (,parms ,body ,env ,form)
- ,*forms))
- ,keyword))
+ . forms)
+ (let ((lambda ^(lambda (,parms ,body ,env ,form) ,*forms)))
+ (set-macro-ancestor lambda f)
+ ^(progn
+ (set [*param-macro* ,keyword] ,lambda)
+ ,keyword)))
(defun macroexpand-params (prototype-form : env)
(tree-case prototype-form