summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-03-24 19:55:53 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-03-24 19:55:53 -0700
commitd6d59c5551a16b5d81779de29e80ffa1065a4275 (patch)
tree04d181db08dd2d3fcbdf0b2d8b6d235829a4342b
parent3e7368db7c823e747c791d9857a5e1f810b9afba (diff)
downloadtxr-d6d59c5551a16b5d81779de29e80ffa1065a4275.tar.gz
txr-d6d59c5551a16b5d81779de29e80ffa1065a4275.tar.bz2
txr-d6d59c5551a16b5d81779de29e80ffa1065a4275.zip
trace: wrong function printed in traces.
When tracing for two or more functions is enabled in a single trace form, the the function tracing hooks print the wrong name for all but the rightmost function. * share/txr/stdlib/trace.tl (sys:trace): Fix code which assumes that the each operator binds fresh lexical variables on each iteration. Bind a fresh lexical variable lex-n which copies the current value of the loop variable n, and refer to this lexical out of the tracing lambda.
-rw-r--r--share/txr/stdlib/trace.tl7
1 files changed, 4 insertions, 3 deletions
diff --git a/share/txr/stdlib/trace.tl b/share/txr/stdlib/trace.tl
index 940425c2..6aa80a46 100644
--- a/share/txr/stdlib/trace.tl
+++ b/share/txr/stdlib/trace.tl
@@ -35,18 +35,19 @@
(let* ((prev (or (symbol-function n)
(throwf 'eval-error
"~s: ~s does not name a function" 'trace n)))
+ (lex-n n)
(hook (lambda (. args)
(let ((abandoned t)
(sys:*trace-level* (succ sys:*trace-level*)))
(unwind-protect
(progn
- (sys:trace-enter n args)
+ (sys:trace-enter lex-n args)
(let ((val (apply prev args)))
- (sys:trace-leave n val)
+ (sys:trace-leave lex-n val)
(set abandoned nil)
val))
(if abandoned
- (sys:trace-leave n :abandoned)))))))
+ (sys:trace-leave lex-n :abandoned)))))))
(set [sys:*trace-hash* n] prev)
(set (symbol-function n) hook)))))))