Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-21
09:58 • Closed ticket [2889257fff]: array startsearch and friends do not work on env</... artifact: 5a9a674d5d user: serhiy.storchaka
2009-10-31
08:32 • Open ticket [2889257fff]. artifact: 98e8953dc7 user: mistachkin
2009-10-30
17:27 • Pending ticket [2889257fff]. artifact: 2bc41a6b5d user: msofer
06:28 • New ticket [2889257fff]. artifact: 59bb2fea2b user: mistachkin

[array startsearch] and friends do not work on env

Closed / Duplicate2889257fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 43 days ago
Descriptionplain2009-10-30 06:28:10
My research indicates this is due to the EnvTraceProc function calling the function TclSetupEnv for all [array] related trace operations, which deletes the entire global env array and any/all existing array searches with it as part of the process of "synchronizing" the contents of the env array with the actual environment.  Therefore, it is impossible to actually use the array search functionality with the global env array.

This bug also seems to apply to Tcl 8.4 and 8.5.

Example:

set s [array startsearch env]; # returns OK, s-1-env
array nextelement env $s; # returns ERROR, couldn't find search "s-1-env"
msoferplain2009-10-30 17:27:02
Duplicate: #1787911.

This way since 7.6 AFAIU, hard to define proper semantics. Solution might be to only use [array names] on env
mistachkinplain2009-10-31 08:32:52
This limitation (not being able to ever perform array searches on the env array) should at least be documented clearly.
serhiy.storchakawiki2026-10-21 09:58:25

Duplicate of [1787911fff]. Array searches on env work since 8.6.2, where [afaff33553] stopped env from being recreated on array access.

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