Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-15
14:14 • Ticket [572889ffff] upvar links do not fire array read trace status still Cl... artifact: 7424ffb02d user: jan.nijtmans
14:13
Workaround for [572889] no longer needed for Tcl 9.x check-in: b74cee085c user: jan.nijtmans tags: core-8-6-branch
14:08
Workaround for [572889] no longer needed for Tcl 9.x check-in: a8fc8dfdd0 user: jan.nijtmans tags: core-9-0-branch
2026-11-14
18:42
Workaround for [572889] no longer needed for Tcl 9.x check-in: 23e46200a7 user: jan.nijtmans tags: trunk, main
2026-11-13
17:51 • Ticket [572889ffff] upvar links do not fire array read trace status still Cl... artifact: 4c50d4e86f user: serhiy.storchaka
17:46
tcltest: on Tcl 9.0 and later, set the auto-configure read trace only on the Option array. Since TIP... closed check-in: 09f2d9ae9f user: serhiy.storchaka tags: tcltest-array-trace-upvar
16:15 • Ticket [572889ffff] upvar links do not fire array read trace status still Cl... artifact: ac4527d245 user: dgp
11:18 • Closed ticket [572889ffff]. artifact: f9de0de8db user: serhiy.storchaka
2003-06-26
23:07 • Ticket [572889ffff]: 1 change artifact: c7b147cbee user: dgp
17:35 • Ticket [572889ffff]: 1 change artifact: f2c3ecc074 user: dkf
2003-04-18
13:28 • Ticket [572889ffff]: 5 changes artifact: 714a556fe5 user: dgp
2002-06-25
00:09 • Ticket [572889ffff]: 7 changes artifact: d018330765 user: dgp
2002-06-24
23:56 • Ticket [572889ffff]: 4 changes artifact: cac83b6822 user: msofer
2002-06-23
21:43 • New ticket [572889ffff]. artifact: 8bbc620c99 user: dgp

upvar links do not fire array read trace

Closed / Fixed572889ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 17 days ago
Descriptionplain2002-06-23 21:43:28
% set a(foo) 1
1
% trace variable a r {puts a ;#}
%  set a(foo)
a
1
% upvar 0 a(foo) baz
%  set baz
1

I would like to see the trace fire when
I read from baz.
Referenced by1
  • 09f2d9ae9ftcltest: on Tcl 9.0 and later, set the auto-configure read trace only on the Option array. Since TIP 634 it also fires when an option is read through the upvar-linked variables, so the per-variable traces, a workaround for [572889ffff], are only needed on Tcl 8.5 and 8.6. check-in2026-11-13 17:46:34
msoferplain2002-06-24 23:56:38
Logged In: YES 
user_id=148712

upvar.n dixit: "If otherVar refers to an element of an
array, then variable traces set for the entire array will
not be invoked when myVar is accessed (but traces on the
particular element will still be invoked). In particular, if
the array is env, then changes made to myVar will not be
passed to subprocesses correctly."

So, is this a bug or a FR? Does it need a TIP?
dgpplain2002-06-25 00:09:53
Logged In: YES 
user_id=80530

Thanks.  If this is to change, it would be a FR/TIP.
Don't feel strong enough about it to do that now,
but I'll shift this over the FR tracker in case
anyone else wants to pick it up.

Note to self: read *all* relevant man pages before
filing bugs...

Workaround seems to be to set traces on both
the source and target of the [upvar].  Works fine,
then, if annoying.
dgpplain2003-04-18 13:28:07
Logged In: YES 
user_id=80530


Joe, you were asking about this on the chat.
dkf Ticket [572889ffff]: 1 change [History diff]2003-06-26 17:35:45
dgp Ticket [572889ffff]: 1 change [History diff]2003-06-26 23:07:55
serhiy.storchakawiki2026-11-13 11:18:45

Implemented by TIP 634 in Tcl 9.0: traces on the whole array now fire when the array element is accessed through an upvar link, and the upvar manual page was updated accordingly.

dgpplain2026-11-13 16:15:31
Please note there is code in the tcltest package 
that is a workaround of the (mis)feature reported
in this ticket.  Someone with the time might examine
whether this workaround can be phased out now.
serhiy.storchakawiki2026-11-13 17:51:03

The workaround is the list of option variables in tcltest, which each get their own auto-configure read trace because a trace on the Option array did not fire through their upvar links. On Tcl 9.0 and later the trace on Option is enough, but tcltest still runs on Tcl 8.6 (and 8.5), where the workaround is still needed.

Proposed change in branch tcltest-array-trace-upvar: the per-variable traces are only set before Tcl 9.0.

jan.nijtmanswiki2026-11-15 14:14:38

Branch branch tcltest-array-trace-upvar is now merged to trunk, core-9-0-branch and core-8-6-branch. Good idea (without any ill-effects)

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