summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-04-05 07:34:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-04-05 07:34:45 -0700
commitbc7a22b3fa9030c3e8d2868f6c9a4c850535b27a (patch)
treeb1b6c03d7bf452e273d7ec181d1518116c199ddd
parent26617e674b5b25760a6f58b24e6618d7f3b58e0c (diff)
downloadtxr-bc7a22b3fa9030c3e8d2868f6c9a4c850535b27a.tar.gz
txr-bc7a22b3fa9030c3e8d2868f6c9a4c850535b27a.tar.bz2
txr-bc7a22b3fa9030c3e8d2868f6c9a4c850535b27a.zip
struct: fix lack of hygiene in null-safe qref.
The expression a.?b is not being treated hygienically; a is evaluated twice. This is only if the null-safe object is the left most; a.b.?c is hygienic. * share/txr/stdlib/struct.tl (qref): Add the necessary gensym use to fix the broken case.
-rw-r--r--share/txr/stdlib/struct.tl4
1 files changed, 3 insertions, 1 deletions
diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl
index 2eecfbc7..ca3de714 100644
--- a/share/txr/stdlib/struct.tl
+++ b/share/txr/stdlib/struct.tl
@@ -211,7 +211,9 @@
(throwf 'eval-error "~s: bad syntax" 'qref))
(tree-case obj
((a b) (if (eq a 't)
- ^(if ,b (qref ,b ,*refs))
+ (let ((s (gensym)))
+ ^(slet ((,s ,b))
+ (if ,s (qref ,s ,*refs))))
:))
(x (tree-case refs
(() ())