Tcl Source Code

View Ticket
Login
Ticket UUID: 6d4319309e906144741e49f8790647b2dffb452a
Title: Parent-Class destructor not invoked with same class-name in different namespace
Type: Bug Version: Itcl 4.3.2
Submitter: anonymous Created on: 2025-02-12 22:37:45
Subsystem: 10. Objects Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2025-02-20 13:04:29
Resolution: Fixed Closed By: sebres
    Closed on: 2025-02-20 13:04:29
Description:
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.
User Comments: sebres added on 2025-02-20 13:04:29:

Yes, my suspicion about simple name in hash table has been confirmed...
Fixed in [itcl/883c2c383fee7603], related ticket [itcl/987067386fa2edae].


sebres added on 2025-02-13 22:06:57:

It seems to be solely Itcl (v.4) issue (thus the correct place for the ticket would be itcl/ticket).

Below enclosed the PoC for tclOO (basis of Itcl since Itcl4), that works as expected:

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).


Attachments: