Tcl Source Code

View Ticket
Login
Ticket UUID: 3609693
Title: copied object member variable confusion
Type: Bug Created on: 2013-04-01 13:41:41
Submitter: pooryorick Assigned to: dkf
Subsystem: 35. TclOO Package Severity: Important
Priority: 8 Last modified: 2013-09-09 14:13:42
Status: Closed Closed by: dkf
Resolution: Fixed Closed on: 2013-09-09 14:13:42
Version: current: 8.6.0
Description:
In the following script, $obj2 thinks the value of its $var1 is "val1"


namespace import oo::*
set obj [object new]
objdefine $obj variable var1 
objdefine $obj method m {} {
    set var1 val1
}
objdefine $obj method get {} {
    return $var1
}

$obj m
$obj get
set obj2 [oo::copy $obj]
${obj2}::my eval {
    set var1 val2
}
puts [$obj2 get]
User Comments:
dkf added on 2013-04-01 23:46:05:
Looks like there's a cached reference to the variable in the method implementation, which is indeed the case because that's how variable references in object-specific methods are bound. The method cloner needs work...

dkf added on 2013-08-21 09:38:47:

Committed a test to branch bug-3609693, but the code I've got to try and fix this crashes quite a distance away; I'm doing something wrong, but I don't know what.


dkf added on 2013-09-09 13:37:24:

Ah! Needed to strip the internal representation from the body to prevent some strange things from happening. Fixed now.


dkf added on 2013-09-09 14:02:05:

Damn. This breaks itcl completely.


dkf added on 2013-09-09 14:13:42:

False alarm; that crash happens without this change too. Whatever's going on, it's not this.