From bc7a22b3fa9030c3e8d2868f6c9a4c850535b27a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 5 Apr 2021 07:34:45 -0700 Subject: 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. --- share/txr/stdlib/struct.tl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 (() ()) -- cgit v1.2.3