Tcl Source Code

View Ticket
Login
Ticket UUID: 68050339b564d3c155cb9d9b324262ed7b3b65f3
Title: classmethod fails if no argument supplied to class create
Type: Bug Version: 9.0b3
Submitter: apnadkarni Created on: 2024-08-26 12:07:16
Subsystem: 35. TclOO Package Assigned To: dkf
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2024-09-16 19:08:29
Resolution: Fixed Closed By: dgp
    Closed on: 2024-09-16 19:08:29
Description:
% oo::class create C
::C
% oo::define C {method m {} {}}
% oo::define C {classmethod cm {} {}}
::oo::Obj23:: oo ::delegate does not refer to an object

Note method works, but not classmethod. On the other hand, if the create is passed a body (even empty), it all works.

% oo::class create D {}
::D
% oo::define D {method m {} {}}
% oo::define D {classmethod cm {} {}}

Very minor but spent a half hour not understanding why my code was suddenly failing after adding a classmethod :-)

User Comments: dgp added on 2024-09-16 19:08:29:
This bug fix applied to Tcl trunk creates three test failures
in Itcl 4.3.0

typeclass.test


==== rename-1.3 rename to "" deletes an instance FAILED
==== Contents of test case:

    type dog { }

    dog fido
    rename fido ""
    namespace children ::dog

---- Result was:
{::dog:: oo }
---- Result should have been (exact matching):

==== rename-1.3 FAILED



==== rename-1.4 rename to "" deletes an instance even after a rename FAILED
==== Contents of test case:

    type dog { }

    dog fido
    rename fido spot
    rename spot ""
    namespace children ::dog

---- Result was:
{::dog:: oo }
---- Result should have been (exact matching):

==== rename-1.4 FAILED



==== destroy-1.1 destroy cleans up the instance FAILED
==== Contents of test case:

    type dog {
        option -color golden
    }

    set a [namespace children ::dog::]
    dog create spot
    set ns [info object namespace spot]
    set b [namespace children ::itcl::internal::variables$ns]
    spot destroy
    set c [namespace which ::itcl::internal::variables$ns]
    list $a $b $c [info commands ::dog::spot]

---- Result was:
{{::dog:: oo }} ::itcl::internal::variables::oo::Obj123::dog {} {}
---- Result should have been (glob matching):
{} ::itcl::internal::variables::*::dog {} {}
==== destroy-1.1 FAILED

oehhar added on 2024-09-16 14:44:06:

Great fix! The commit is [b378bba6ce].


dkf added on 2024-09-16 14:41:11:

Oh, that was silly. Was checking the number of arguments to the class constructor too early. Moved the check after the creation of the delegate.


dkf added on 2024-09-16 14:26:21:

Very odd. That should work...