Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-04-26
13:27
merge 8.6 (fixes [27520c9b17]) check-in: 9427d5662e user: sebres tags: core-8-branch
12:29 • Closed ticket [27520c9b17]: try/finally bytecode optimizer incorrect order of op... artifact: 83ba32c449 user: sebres
12:28
closes bug [27520c9b17] check-in: 642ae7905b user: sebres tags: core-8-6-branch
12:11 • Ticket [27520c9b17] try/finally bytecode optimizer incorrect order of operations... artifact: 550f874598 user: sebres
12:03
fixes compilation of try-command [27520c9b17]: compile only if finaly token is simple closed check-in: fba9450772 user: sebres tags: bug-27520c9b17
12:03
added test illustrating bug [27520c9b17] check-in: b6e28a1636 user: sebres tags: bug-27520c9b17
2022-04-21
21:30 • New ticket [27520c9b17] try/finally bytecode optimizer incorrect order of operat... artifact: 442b482f47 user: andy

try/finally bytecode optimizer incorrect order of operations

Closed / Fixed27520c9b17116d8d34c1874e4e9ec9d350ad579eCreated 5 years agoUpdated 5 years ago
Descriptionplain2022-04-21 21:30:47
There appears to be a problem with the bytecode optimizer for [try].  If the argument after "finally" contains substitutions, they are not evaluated until it actually comes time to execute the "finally" block.

Consider:

try {puts a} finally [puts b]

This should print "b a" (newline in between) because the [puts b] needs to be evaluated in the process of assembling the command line, before even executing it.  However, it prints "a b" instead.

If the command line is instead written:

{*}[list] try {puts a} finally [puts b]

it prints "b a" as expected.  This is because the bizarre invocation of [list] bypasses the bytecode optimizer, allowing the normal Tcl order of operations to prevail.
Referenced by4
sebreswiki2022-04-26 12:11:36

I fixed that (already in 2019) but somehow missed to provide the fix in tcl-core.

Rebased now to related fossil revision (could be safely merged in current 8.6) as branch bug-27520c9b17.

sebreswiki2022-04-26 12:29:16

Fixed (merged in current 8.6)

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