diff options
| author | dkf <donal.k.fellows@manchester.ac.uk> | 2024-07-14 20:07:13 (GMT) |
|---|---|---|
| committer | dkf <donal.k.fellows@manchester.ac.uk> | 2024-07-14 20:07:13 (GMT) |
| commit | 5efbb59798a8d4e0247ab3202ea9cb691ab259ba (patch) | |
| tree | 2fcf78ebbd1e2dfc19463cb5685e4ee8c9938ad5 | |
| parent | a7637024f44703fa640cf8c4fc382a8a6347cba0 (diff) | |
| parent | b934bdeb1144263a4f7ca66ab9bbf3e27676d568 (diff) | |
| download | tcl-5efbb59798a8d4e0247ab3202ea9cb691ab259ba.zip tcl-5efbb59798a8d4e0247ab3202ea9cb691ab259ba.tar.gz tcl-5efbb59798a8d4e0247ab3202ea9cb691ab259ba.tar.bz2 | |
Stop variable from disappearing by accident when referred to by name. [74b6110204]
| -rw-r--r-- | generic/tclOOBasic.c | 5 | ||||
| -rw-r--r-- | tests/oo.test | 14 |
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 { |
