Skip to content
Tcl Source Code View Ticket
Login

View Ticket

TclOO: varnames incorrect when used from other object method

Closed / Fixed3603695fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2013-02-07 12:04:39
When using oo::object's varname method on an object within the context of another object's method, [$other varname x] returns as if invoked as [my varname x]. Changing the context (e.g. by using [uplevel #0 $other varname x]) returns the correct result. Example code and output attached.

Tcl Version: 8.6.0
TclOO Version: 1.0
OS Platform & Version: Linux 3.5.7
taylor_venableplain2013-02-07 19:04:40
File Added - 460258: test.tcl
dkfplain2013-02-08 21:00:58
The 'variable' declaration is critical to the problem, as the test case I'm working on (see below) succeeds without it and fails with it. Very strange!

test oo-19.3 {OO: varname method and variable decl: Bug 3603695} -setup {
    oo::class create testClass {
variable foo
export varname
constructor {} {
    variable foo x
}
method bar {obj} {
    my varname foo
    $obj varname foo
}
    }
} -body {
    testClass create A
    testClass create B
    lsearch [list [A varname foo] [B varname foo]] [B bar A]
} -cleanup {
    testClass destroy
} -result 0
dkfplain2013-02-09 19:32:28
allow_comments - 1

Fixed for the next release of Tcl 8.6; will also apply to TclOO package for its future releases.
Log in (anonymous is fine) to add a comment.

Attachments: