summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 11af6a2..6dc8f56 100644
--- a/generic/tclOOBasic.c
+++ b/generic/tclOOBasic.c
@@ -830,6 +830,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 2e31c63..3d32e2b 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -3079,6 +3079,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 {