Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2020-09-19
17:28 • Ticket [9eac2d8a8d] uplevel: level sniffing for single arg, default-level case (... artifact: 46fed0a6ac user: pooryorick
2019-05-08
18:50 • Ticket [9eac2d8a8d]: 3 changes artifact: cb7dbe76da user: dgp
18:00 • Ticket [9eac2d8a8d]: 3 changes artifact: 50200fe803 user: dgp
2019-05-07
22:07 • New ticket [9eac2d8a8d]. artifact: 7641c74042 user: anonymous

uplevel: level sniffing for single arg, default-level case (absolute level specifier only)

Open9eac2d8a8d6da83d4554afd55865a54691c4c58dCreated 8 years agoUpdated 6 years ago
Descriptionplain2019-05-07 22:07:05
Following up on the conversation at IRC:

«dkf» We used to do a nonsense parse where if the first argument started with a digit (IIRC), Tcl would assume that it was a level _even if that meant there were no other arguments_ (which was an error case)

«dkf» it shouldn’t ever consider an argument to be a level if there’s only one argument

In current 8.7, this holds but not for a single arg starting with a hash:

% namespace eval ::ns1 { uplevel {#0 b}}}
bad level "#0 b"

should read: invalid command "#0"

«dkf» ’tis a bug
«dkf» in 8.7
dgpplain2019-05-08 18:00:00
For some history, see

https://core.tcl-lang.org/tcl/tktview/2673163

https://core.tcl-lang.org/tcl/info/1c6d19544d18c36a
dgpplain2019-05-08 18:50:07
The documentation for [uplevel]:

    https://www.tcl-lang.org/man/tcl8.7/TclCmd/uplevel.htm

clearly states " Level cannot be defaulted if the first command argument starts with a digit or #. "

So this is not a bug, but it is a report of absolutely boneheaded behavior.

We should TIP the fix, using the fact that we already did this for
[upvar] as justification.
pooryorickwiki2020-09-19 17:28:27

See ticket [b9ecf3ce98] for a backwards-compatible solution that addresses most practical concerns by interpreting the first argument as a script if it is the only argument and is a list containing more than one item.

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