Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-07-29
19:41 • Ticket [600812ffff] upvar can create unusable variable status still Closed w... artifact: 7ae3cecdbf user: dkf
2008-11-02
18:27 • Ticket [600812ffff]: 7 changes artifact: 6d90247e90 user: dkf
2004-04-28
20:13 • Closed ticket [600812ffff]. artifact: ebf8a6f540 user: msofer
2003-11-11
04:11 • Ticket [600812ffff]: 5 changes artifact: 844f6a9fe1 user: hobbs
2003-11-10
23:48 • Ticket [600812ffff]: 4 changes artifact: 19e066f5a8 user: msofer
23:48 • Add attachment 600812.patch to ticket [600812ffff] artifact: 8ff87b720a user: msofer
23:48 • Ticket [600812ffff] upvar can create unusable variable status still Open wit... artifact: 92a373f458 user: msofer
22:36 • Ticket [600812ffff]: 1 change artifact: 31293561c7 user: dgp
22:33 • Ticket [600812ffff]: 4 changes artifact: a03d645742 user: dgp
08:52 • Ticket [600812ffff]: 5 changes artifact: f727b718ba user: msofer
2003-10-21
05:12 • Ticket [600812ffff]: 4 changes artifact: 0ee14eb2c6 user: msofer
05:12 • Ticket [600812ffff]: 1 change artifact: 846f2b478d user: msofer
05:09 • Ticket [600812ffff]: 4 changes artifact: 70148292a9 user: msofer
2002-08-27
14:26 • New ticket [600812ffff]. artifact: 0756c97dce user: dgp

upvar can create unusable variable

Closed600812ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 17 years ago
Descriptionplain2002-08-27 14:26:39
set scalar test
array set array {foo bar}
upvar 0 scalar array(grok)
set array(grok)
=> can't read "array(grok)": no such element in array

A scalar (link) variable named "array(grok)" has been
created, but there is no mechanism at the script
level for doing anything with it.

Seems [upvar] should fail rather than give something
that can't be used.
msoferplain2003-10-21 05:09:18
Logged In: YES 
user_id=148712

Duplicated as 826708 by rmax; initial comment there:

" As discussed with dkf on the Tcl'ers chat...
It works as documented, and treats b(c) as a literal
variable name (not as an array). But because this
variable can never be accessed with [set] or
$-substitution, [upvar] should rather fail on such
variable names, or (IMHO better) it should create an
array element, if that's possible at all."
msofer Ticket [600812ffff]: 1 change [History diff]2003-10-21 05:12:38
msoferplain2003-10-21 05:12:39
Logged In: YES 
user_id=148712

Failure it will be; creating the array is quite a
modification ...
msoferplain2003-11-10 08:52:21
File Added - 66969: 600812.patch

Logged In: YES 
user_id=148712

Attaching a patch for review - in particular, the doc
changes. This does not require a TIP, does it?
dgpplain2003-11-10 22:33:38
Logged In: YES 
user_id=80530


It seems this misfeature is
documented in upvar.n, and
has been documented this
way "forever" (since at least
Tcl 7.4).  Makes me wonder
whether this made sense at
one pont, and variable parsing
rules have changed over the
years to more aggressively
recognize arrays?

Seems we ought to have a 
brief TIP, if only to let the
wise old men have a look and
confirm we're not overlooking
something.

Otherwise, the patch looks fine.
If it's not too much trouble, I'd
update your new tests to use
the -returnCodes option.  You
might also want to note in your
new code in ObjMakeUpvar
that your detection of a bad name
for a scalar is consistent (and must
remain consistent) with the code
in TclObjLookupVar (currently
line 447).
dgp Ticket [600812ffff]: 1 change [History diff]2003-11-10 22:36:07
msoferplain2003-11-10 23:48:27
Logged In: YES 
user_id=148712

Patch updated; mini TIP in prep
msoferplain2003-11-10 23:48:28
File Deleted - 66969: 



File Added - 67035: 600812.patch
hobbsplain2003-11-11 04:11:17
Logged In: YES 
user_id=72656

There used to be slightly different behavior in nested array in 
Tcl 7.x.  When the requests for proper first-class array 
support came in, noting the then existent behavior, that was 
actually removed by JO.  You can't do nested arrays now.
This should be considered for 8.5, but really may be a 9.0 
behavior for the change in error status.
msoferplain2004-04-28 20:13:17
Logged In: YES 
user_id=148712

Tip 184 accepted, patch committed.
dkfplain2008-11-02 18:27:22
data_type - 210894
dkfplain2009-07-29 19:41:45
IP - Comment Removed: 130.88.1.31
Log in (anonymous is fine) to add a comment.

Attachments: