diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-05-14 09:32:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-05-14 09:32:23 -0700 |
commit | 30b4cd7fd4aa40616e089b834e34f1928c700ab1 (patch) | |
tree | 6aee301a40e21b6950ea1ca5f8bd6dff40f0229d /tests | |
parent | 5162fde5237ce801f74e8db2bc680f72f00fb0ce (diff) | |
download | txr-30b4cd7fd4aa40616e089b834e34f1928c700ab1.tar.gz txr-30b4cd7fd4aa40616e089b834e34f1928c700ab1.tar.bz2 txr-30b4cd7fd4aa40616e089b834e34f1928c700ab1.zip |
bug: symbol-value place always global.
We have a problem. If v is a dynamic variable, then
the form
(let (v)
(set (symbol-value 'v) 3))
is not behaving correctly; it's updating the top-level
value of v not the rebound one.
* eval.c (set_symbol_value): New static function.
(eval_init): Register sys:set-symbol-value intrinsic.
The top-vb variable, though no longer referenced by
the symbol-value place, because existing compiled
code depends on it.
* stdlib/place.tl (symbol-value): Rewrite the place
logic to use symbol-value to access the variable,
and set-symbol-value to update it, instead of referencing
sys:top-vb.
(sys:get-vb): This function has to stay, because it
provides run-time support for code compiled with the
buggy version of the place.
* tests/019/symbol-value.tl: New file.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/019/symbol-value.tl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/019/symbol-value.tl b/tests/019/symbol-value.tl new file mode 100644 index 00000000..ca724f5a --- /dev/null +++ b/tests/019/symbol-value.tl @@ -0,0 +1,24 @@ +(load "../common") + +(defparm v 42) + +(mtest + v 42 + (symbol-value 'v) 42 + (set (symbol-value 'v) 73) 73 + (symbol-value 'v) 73 + v 73) + +(mtest + (let ((v 2)) v) 2 + (let ((v 2)) (symbol-value 'v)) 2 + (progn (let ((v 2)) (set (symbol-value 'v) 1)) v) 73 + (let ((v 2)) (set (symbol-value 'v) 1) v) 1 + v 73) + +(test + (progn + (let ((v 2)) + (set (symbol-value 'x) 73)) + x) + 73) |