Tcl Source Code

View Ticket
Login
Ticket UUID: 934e6eb9cf15782433ffbc2f56cecdac30c596f5
Title: ensemble unknown handler confused by tailcall
Type: Bug Created on: 2020-01-03 20:04:41
Submitter: pooryorick Assigned to: nobody
Subsystem: 21. [namespace] Severity: Important
Priority: 5 Medium Last modified: 2021-06-21 06:47:43
Status: Open Closed by: nobody
Resolution: None Closed on:
Version:
Description:

tailcall confuses the unknown handler of a namespace ensemble. The following script,

namespace eval ns1 {
    proc dispatch {routine args} {
        return list
    }
    namespace ensemble create -unknown [
    list ::apply [list {ensemble routine args} {
        tailcall dispatch $routine {*}$args
    } [namespace current]]]
}

puts [ns1 x one two three]

results in the error:

unknown subcommand "x": namespace ::ns1 does not export any commands

However, if the word "tailcall" is removed, then the result is as expected:

one two three