Tcl Source Code

View Ticket
Login
Ticket UUID: 1706593
Title: autoloading causes (itcl) 'class already exists' error
Type: Bug Version: obsolete: 8.4.14
Submitter: legolas_a20 Created on: 2007-04-24 13:16:16
Subsystem: 38. Init - Library - Autoload Assigned To: dgp
Priority: 5 Medium Severity:
Status: Open Last Modified: 2007-04-24 20:16:18
Resolution: None Closed By:
    Closed on:
Description:
There is a 'bug' in the itcl implementation of auto_mkindex_parser::command, that causes an error message saying:
class "::A" already exists
if it is combined with a simple error in the itcl class and autoloading.


I realize this is not completely a tcl core problem, however the autoload package already appears to try to 'defend' against errors in external parser commands, and if this case could also be caught, it could return a much better error message.

Example in the attachment, in short: itcl allows you to declare a proc but implement it later (C++ style separation of header and implementation). itcl has implemented the parsing for autoload by adding the proc to the autoload list when the declaration is seen (probably because you can also implement the proc inline with the declaration, again matching C++ style.)

Now, if you declare but not implement a proc, it is listed in the tclindex file, but after sourcing the file, the command is still not defined. However, the current checks against this all pass.
Then, the command is started, causing a recursive call into the autoload code, which sources the file again, which results in the error.

(I have tried to reproduce this without itcl, but haven't been able to. I don't fully understand how itcl creates it's class procedures as tcl procs and namespaces, and how this succeeds in bypassing the existing checks.)

Note: tested using itcl 3.3, everything was installed by activestate's 8.4.14 tcl installer, on windows xp sp2.
User Comments: legolas_a20 added on 2007-04-24 20:16:18:

File Added - 226391: tclbug.zip

Attachments: