Artifacts Associated With Ticket ecf35c71200d782c
Ticket change [7651e27eb7] (rid 241783) by dgp on 2025-06-20 15:33:36:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-plain"
- comment initialized to:
While out on an arduous hunt for a memory leak, I noticed that the coding of TclMergeReturnOptions() contains an ordering error which can be demonstrated in an interactive session: % catch {return -level 0 -options {-options {-code break} -code ok}} m o 3 % set o -code 3 -level 0 - foundin initialized to: "8.5+"
- is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- private_contact initialized to: "8e2300e85be5dd1445b9666eb9429055951e33be"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "45. Parsing and Eval"
- title initialized to: "[return]: broken ordering of nested -options"
- type initialized to: "Bug"
Ticket change [30b6187c96] (rid 241787) by dgp on 2025-06-20 15:46:49:
- 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"
- icomment:
Ticket change [c8e191e8d4] (rid 241788) by dgp on 2025-06-20 15:50:24:
- icomment:
Note that only nesting brings out the trouble. A single level of -options behaves properly % catch {return -level 0 -options {-code break} -code ok} m o 0 % set o -code 0 -level 0 - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [2e1c5353c9] (rid 241887) by dgp on 2025-06-23 17:42:17:
- icomment:
Branch bug-ecf35c7120 is open to address this ticket. So far it includes tests demonstrating the problem. Briefly, processing so that the -options switch emulates {*} argument expansion is not consistent with standard dictionary creation processing in the handling of duplicate keys. - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [e44c542315] (rid 241889) by dgp on 2025-06-23 19:59:06:
- icomment:
A pending fix is committed to the bugfix branch.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [64bab9c8b9] (rid 241924) by dgp on 2025-06-24 16:24:36:
- assignee changed to: "dgp"
- closedate changed to: "2460851.18375855"
- closer changed to: "dgp"
- icomment:
Fix accepted into the 9.0 branch
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"