Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Compiled [self n] returns the namespace instead of an ambiguous subcommand error

Pending8ab06e31e3af6141118a547d52e4636fba9ef252Created 51 days agoUpdated 45 days ago
Descriptionwiki2026-10-12 20:36:12
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.

Referenced by2
  • 313bb0bb1dFix [8ab06e31e3]: compiled [self n] returned the namespace instead of the "ambiguous subcommand" error of the command, since n is also a prefix of next. Require at least "na" for namespace. check-in2026-10-14 08:02:17
  • 49311822fdTicket [3069454fff] difference between bcc'ed and eval'ed regexp status still Open with 3 other changes ticket2026-10-12 20:37:46
serhiy.storchakawiki2026-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.nijtmanswiki2026-10-18 21:14:13

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

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

Log in (anonymous is fine) to add a comment.