diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-13 20:56:23 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-13 20:56:23 -0800 |
commit | 13a808b5fda3ce75025c6ad8b67e3a5422602c17 (patch) | |
tree | 7637f01321f70986bee942428ba3c294063bba67 /share | |
parent | e98737b05917ebeaad6a8868e8d4d3cc6e5a89b2 (diff) | |
download | txr-13a808b5fda3ce75025c6ad8b67e3a5422602c17.tar.gz txr-13a808b5fda3ce75025c6ad8b67e3a5422602c17.tar.bz2 txr-13a808b5fda3ce75025c6ad8b67e3a5422602c17.zip |
Fix spectacular bug in number of syntactic places.
Test case: (symacrolet ((f g)) (set [f x] y)) fails to expand.
The root cause is that f is not expanded, because a nil
environment is passed down to with-update-expander macro.
This problem affects not only the dwim place, but nthcdr,
sub and others.
This bug was surprising at first because the Awk macro
establishes the field array f via symbol macro. But
assignments like (set [f 0] ...) worked!
The thing is, they only worked by fluke due to the
way expansions are handled in the Awk macro. That fluke
came to an end in the November 4 commit
157fd76ee20125f409929b95b768b931268b43cf, just before 156
was released. The changes there don't cause this problem,
but they remove the circumstances which protect the awk
macro from the problem. So yes, that commit effectively
caused another regression in 156: assignment to awk fields
not working.
* share/txr/stdlib/place.tl (nthcdr, nthlast, ref, sub,
dwim): Do not pass an environment value of nil to
with-update-expander! Pass the value of the special variable
sys:*pl-env* which is there exactly for this purpose:
to give to place expanders like these the original macro
environment where the form occurs, so they can expand
embedded places.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/place.tl | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 12ad1b71..a61fb99b 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -472,7 +472,7 @@ (getter setter (with-gensyms (index-sym list-sym sentinel-head-sym parent-cell-sym) (if (place-form-p list sys:*pl-env*) - (with-update-expander (lgetter lsetter) list nil + (with-update-expander (lgetter lsetter) list sys:*pl-env* ^(alet ((,index-sym ,index) (,list-sym (,lgetter))) (let* ((,sentinel-head-sym (cons nil ,list-sym)) @@ -494,7 +494,7 @@ (getter setter (with-gensyms (index-sym list-sym sentinel-head-sym parent-cell-sym) (if (place-form-p list sys:*pl-env*) - (with-update-expander (lgetter lsetter) list nil + (with-update-expander (lgetter lsetter) list sys:*pl-env* ^(alet ((,index-sym ,index) (,list-sym (,lgetter))) (let* ((,sentinel-head-sym (cons nil ,list-sym)) @@ -516,7 +516,7 @@ (defplace (butlastn num list) body (getter setter (with-gensyms (num-sym list-sym head-sym tail-sym val-sym) - (with-update-expander (lgetter lsetter) list nil + (with-update-expander (lgetter lsetter) list sys:*pl-env* ^(alet ((,num-sym ,num) (,list-sym (,lgetter))) (let* ((,tail-sym (nthlast ,num-sym ,list-sym)) @@ -595,7 +595,7 @@ (defplace (sub seq :whole args : (from 0) (to t)) body (getter setter (with-gensyms (seq-sym from-sym to-sym v-sym) - (with-update-expander (seq-getter seq-setter) seq nil + (with-update-expander (seq-getter seq-setter) seq sys:*pl-env* ^(alet ((,seq-sym (,seq-getter)) (,from-sym ,from) (,to-sym ,to)) @@ -608,7 +608,7 @@ ,body))))) (ssetter (with-gensyms (seq-sym from-sym to-sym v-sym) - (with-update-expander (seq-getter seq-setter) seq nil + (with-update-expander (seq-getter seq-setter) seq sys:*pl-env* ^(macrolet ((,ssetter (val) ^(alet ((,',seq-sym (,',seq-getter)) (,',from-sym ,',from) @@ -620,7 +620,7 @@ ,body)))) (deleter (with-gensyms (seq-sym from-sym to-sym) - (with-update-expander (seq-getter seq-setter) seq nil + (with-update-expander (seq-getter seq-setter) seq sys:*pl-env* ^(alet ((,seq-sym (,seq-getter)) (,from-sym ,from) (,to-sym ,to)) @@ -670,7 +670,7 @@ (let ((arg-syms (mapcar (ret (gensym)) args)) (sys:*lisp1* t)) (if (place-form-p obj-place sys:*pl-env*) - (with-update-expander (ogetter-sym osetter-sym) obj-place nil + (with-update-expander (ogetter-sym osetter-sym) obj-place sys:*pl-env* ^(rlet ((,obj-sym (,ogetter-sym)) ,*(mapcar (ret ^(,@1 (sys:l1-val ,@2))) arg-syms args)) (macrolet ((,getter () @@ -697,7 +697,7 @@ (let ((arg-syms (mapcar (ret (gensym)) args)) (sys:*lisp1* t)) (if (place-form-p obj-place sys:*pl-env*) - (with-update-expander (ogetter-sym osetter-sym) obj-place nil + (with-update-expander (ogetter-sym osetter-sym) obj-place sys:*pl-env* ^(macrolet ((,ssetter (val) ^(rlet ((,',obj-sym (,',ogetter-sym)) ,*(mapcar (ret ^(,@1 (sys:l1-val ,@2))) @@ -725,7 +725,7 @@ (let ((arg-syms (mapcar (ret (gensym)) args)) (sys:*lisp1* t)) (if (place-form-p obj-place sys:*pl-env*) - (with-update-expander (ogetter-sym osetter-sym) obj-place nil + (with-update-expander (ogetter-sym osetter-sym) obj-place sys:*pl-env* ^(macrolet ((,deleter () ^(rlet ((,',obj-sym (,',ogetter-sym)) ,*(mapcar (ret ^(,@1 (sys:l1-val ,@2))) |