Tcl Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to
or submit via the online form by Aug 20.
Ticket UUID: 9d61624b3deb9fc676d69a59e0213e61cf8e5fb1
Title: empty superclass slot is not always equivalent to oo::object
Type: Bug Version: 8.6.0
Submitter: anonymous Created on: 2013-07-07 22:17:10
Subsystem: 35. TclOO Package Assigned To: dkf
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2013-08-02 15:00:08
Resolution: Fixed Closed By: dkf
    Closed on: 2013-08-02 15:00:08
If you do not define a superclass for $class, then oo::object will be
the superclass of $class. This is explained in the documentation
(of oo::define) as "an empty parent class is equivalent to oo::object".
However, if you do oo::define $class { superclass }, then the superclass
slot is made empty, but does not again become equivalent to oo::object.
A crash can be caused. Example:

% oo::class create fruit {
    method eat {} {
        puts "yummy!"
% set f [fruit new]
% info object class $f oo::object
% info class superclasses fruit
% oo::define fruit { superclass }
% info class superclasses fruit
% info object class $f oo::object
% info object isa object $f
% $f destroy 
impossible to invoke method "destroy": no defined method or unknown method
% info class call fruit destroy
cannot construct any call chain
% $f
Segmentation fault (core dumped)

-Marcel van der Goot
User Comments: dkf added on 2013-08-02 14:37:40: (text/x-fossil-wiki)
Confirmed interactively. Ouch.