summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2024-07-14 20:06:39 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2024-07-14 20:06:39 (GMT)
commitb733648e8509bdba457d2f7387bd9029be84d2c2 (patch)
tree80fa2151b959ddc3b318e7037ca076da151e684d
parentd4a730f62917025a4d2b59a1dd6e630226b1f4f5 (diff)
parent7cb086504f107b8de60f5c8c1c7afddcd0649421 (diff)
downloadtcl-b733648e8509bdba457d2f7387bd9029be84d2c2.zip
tcl-b733648e8509bdba457d2f7387bd9029be84d2c2.tar.gz
tcl-b733648e8509bdba457d2f7387bd9029be84d2c2.tar.bz2
Stop variable from disappearing by accident when referred to by name. [74b6110204]
-rw-r--r--generic/tclOOBasic.c5
-rw-r--r--tests/oo.test14
2 files changed, 19 insertions, 0 deletions
diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c
index b5b3265..7b4ad5c 100644
--- a/generic/tclOOBasic.c
+++ b/generic/tclOOBasic.c
@@ -827,6 +827,11 @@ TclOO_Object_VarName(
}
/*
+ * The variable reference must not disappear too soon. [Bug 74b6110204]
+ */
+ TclSetVarNamespaceVar(varPtr);
+
+ /*
* Now that we've pinned down what variable we're really talking about
* (including traversing variable links), convert back to a name.
*/
diff --git a/tests/oo.test b/tests/oo.test
index 0ac7f86..0838827 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -3055,6 +3055,20 @@ test oo-19.3 {OO: varname method and variable decl: Bug 3603695} -setup {
} -cleanup {
testClass destroy
} -result 0
+test oo-19.4 {OO: varname ghosts [Bug 74b6110204]} -setup {
+ oo::class create testClass {
+ export varname
+ self export createWithNamespace
+ }
+ set obj [testClass createWithNamespace testoo19_4 testoo19_4]
+ set ns [info object namespace $obj]
+} -body {
+ set v [$obj varname foo]
+ list [namespace which -variable $v] \
+ [info exists $v] [namespace which -variable $v]
+} -cleanup {
+ testClass destroy
+} -result {::testoo19_4::foo 0 ::testoo19_4::foo}
test oo-20.1 {OO: variable method} -body {
oo::class create testClass {