From 5bb2c0f79e82fe0089b7f0ea89312f27753be4f9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 8 Apr 2018 07:24:11 -0700 Subject: trace: bugfix: redefine check mustn't throw exceptions. * share/txr/stdlib/trace.tl (sys:trace-canonicalize-name): Don't call static-slot-home on something that might not be a struct type symbol. Otherwise the trace module will throw whenever some lookup is performed for a non-existent method. That means that when trace is loaded, it is impossible to define a method with defun. --- share/txr/stdlib/trace.tl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/share/txr/stdlib/trace.tl b/share/txr/stdlib/trace.tl index 44dba55f..4815ab4f 100644 --- a/share/txr/stdlib/trace.tl +++ b/share/txr/stdlib/trace.tl @@ -41,12 +41,16 @@ (defun sys:trace-canonicalize-name (name) (if (and (consp name) (eq (car name) 'meth)) - (let* ((req-type (cadr name)) - (sym (caddr name))) - (let ((actual-type (static-slot-home req-type sym))) - (if (eq req-type actual-type) - name - ^(meth ,actual-type ,sym)))) + (let* ((req-type-sym (cadr name)) + (slot-sym (caddr name)) + (req-type (find-struct-type req-type-sym)) + (s-s-p (if req-type + (static-slot-p req-type slot-sym))) + (actual-type-sym (if s-s-p + (static-slot-home req-type-sym slot-sym)))) + (if (and s-s-p (neq req-type-sym actual-type-sym)) + ^(meth ,actual-type-sym ,slot-sym) + name)) name)) (defun sys:trace (names) -- cgit v1.2.3