Tcl Source Code

View Ticket
Login
Ticket UUID: 8ab06e31e3af6141118a547d52e4636fba9ef252
Title: Compiled [self n] returns the namespace instead of an ambiguous subcommand error
Type: Bug Created on: 2026-10-12 20:36:12
Submitter: serhiy.storchaka Assigned to: jan.nijtmans
Subsystem: 47. Bytecode Compiler Severity: Minor
Priority: 5 Medium Last modified: 2026-10-18 21:14:13
Status: Pending Closed by: nobody
Resolution: Fixed Closed on:
Version: 8.6.18, 9.0.5, 9.1.0
Description:

self n is an error ("ambiguous subcommand "n": must be call, caller, class, filter, method, namespace, next, object, or target"), but in compiled code it is accepted as self namespace:

oo::class create C {method m {} {self n}}
[C new] m

The compiler accepts any prefix of namespace, including n, which is also a prefix of next. It has done so since [acbaf52e6e]. na should be the shortest accepted prefix. Since this turns code that works now into an error, the fix is for the next feature release.

User Comments:
serhiy.storchaka added on 2026-10-14 08:03:19:

Proposed fix in branch compile-self-ambiguous: the compiler now requires at least na for namespace, so self n gets the "ambiguous subcommand" error from the command. Test oo-29.2.


jan.nijtmans added on 2026-10-18 21:14:13:

Now merged to [7cd1d5bbe9|trunk] and core-9-0-branch.

Merge to core-8-6-branch still to be done.