Overview
| Artifact ID: | 30b6187c96c7754b4987fe9d949c82edc6bf78539215a43ad509198b60614893 |
|---|---|
| Ticket: | ecf35c71200d782cbd63e15c4df80b5e3c75cbd4
[return]: broken ordering of nested -options |
| User & Date: | dgp on 2025-06-20 15:46:49 |
Changes
- icomment:
The documentation says: -options options The value options must be a valid dictionary. The entries of that dictionary are treated as additional option value pairs for the return command. While an explicit ordering guarantee is not stated, the description suggests a lifting of the dictionary entries out of the dictionary to enter the options alongside the other options. This is the same kind of expansion offered by the {*} syntax, but the -options option debuted at the same time as that syntax, when reliance on it was unclear. An explicit aim was to enable a re-raising pattern: catch $script m o return -options $o $m Had the {*} syntax been better established at the time, we might have gone without -options and prescribed: catch $script m 0 return {*}$o $m Whatever precise mental model is in use, we expect later appearances of the same option to overwrite earlier ones, so that we reason: return -level 0 -options {-options {-code break} -code ok} is same as return -level 0 -options {-code break} -code ok is same as return -level 0 -code break -code ok is same as return -level 0 -code ok and that's not what Tcl is doing. Nested options are rare. A single test even attempts it (cmdMZ-return-2.14), but doesn't illustrate the bug. Not noticed for all this time. - login: "dgp"
- mimetype: "text/plain"