Itcl - the [incr Tcl] extension

View Ticket
Login
Ticket Hash: 987067386fa2edae90f13c464c5081c3881fd0ae
Title: Parent-Class destructor not invoked with same class-name in different namespace
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2025-02-20 12:59:35
137.0 days ago
Created: 2025-02-18 12:37:08
139.0 days ago
Version Found In: 4.3.2
User Comments:
anonymous added on 2025-02-18 12:37:08:

When a class is defined in a namespace and it inherits from a class with the same name from a different namespace and an object from the child class is destroyed, the destructor from the parent class does not get invoked.


anonymous added on 2025-02-18 12:40:18:
Previously submitted as https://core.tcl-lang.org/tcl/tktview/6d4319309e906144741e

PoC ...
namespace eval ::A {}; namespace eval ::B {}
oo::class create ::A::testCls {
  superclass oo::class
  destructor { puts "bye from ::A::testCls" }
}

oo::class create ::C::testOtherCls {
  superclass ::A::testCls
  destructor { puts "bye from ::C::testOtherCls"; next }
}
oo::class create ::C::testCls {
  superclass ::A::testCls
  destructor { puts "bye from ::C::testCls"; next }
}

set o [::C::testOtherCls new]
$o destroy
puts =================
set o [::C::testCls new]
$o destroy

## results to:

bye from ::C::testOtherCls
bye from ::A::testCls
=================
bye from ::C::testCls
bye from ::A::testCls

Although in tclOO inherited destructor need to be invoked explicitly (using next).

I guess, Itcl stores somewhere (hash table?) the chain of destructors by simple name (instead of its reference or fully-qualified name).

sebres added on 2025-02-20 12:59:35:

Yes, my suspicion about simple name in hash table has been confirmed...
Fixed in [883c2c383fee7603], thus close it for now.


Attachments: