Tcl Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Ticket UUID: 3603695
Title: TclOO: varnames incorrect when used from other object method
Type: Bug Version: current: 8.6.0
Submitter: taylor_venable Created on: 2013-02-07 12:04:39
Subsystem: 35. TclOO Package Assigned To: dkf
Priority: 8 Severity:
Status: Closed Last Modified: 2013-02-09 19:32:28
Resolution: Fixed Closed By: dkf
    Closed on: 2013-02-09 12:32:28
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
User Comments: dkf added on 2013-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.

dkf added on 2013-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

taylor_venable added on 2013-02-07 19:04:40:
File Added - 460258: test.tcl