Tcl Source Code

View Ticket
Login
Ticket UUID: 2486824
Title: "upvar" in [global]'s err msg.
Type: Bug Version: obsolete: 8.6b1
Submitter: stwo Created on: 2009-01-05 01:42:54
Subsystem: 07. Variables Assigned To: msofer
Priority: 9 Immediate Severity: Minor
Status: Closed Last Modified: 2014-09-10 08:25:40
Resolution: Fixed Closed By: dkf
    Closed on: 2014-09-10 08:25:40
Description:
% namespace eval n { proc p {} { global a(b) }; p }
bad variable name "a(b)": upvar won't create a scalar variable that looks like an array element
User Comments: dkf added on 2014-09-10 08:25:40:

Sorted on 8.5 and 8.6 branches


aku added on 2014-09-10 06:11:41:
Agreed. I sort of remember that this was ok in some past version, possibly in the 8.4 cycle, and then was changed to this error. Because a scalar looking like an array element was simply all sorts of pain.

I vote for getting rid of the word "upvar" from the generated message.

dkf added on 2014-09-10 05:35:15:

Looks like the right sort of thing.


stwo added on 2012-07-17 01:12:47:
Are we going anywhere with this?

dgp added on 2009-04-09 22:33:41:
Note also this apparent inconsistency:

% proc demo {} {global a(k)}
% demo
bad variable name "a(k)": upvar won't create a scalar variable that looks like an array element
% global a(k)
%

I would think that varNames that look like
array elements ought to be always forbidden
as arguments to [global].

dgp added on 2009-04-03 02:38:05:
Another reason it's generally a bad idea
to include a command name in an error message
is that Tcl commands can be [rename]d.

Let the error message describe the error only;
leave it to -errorinfo to describe the context.

ferrieux added on 2009-01-05 16:30:16:
Agreed, since the overall style of error messages is to omit the command name, and being smart about it involves an ugly switch on the flags parameter in the common code.
For consistency we might do the same to 'upvar won't create namespace variable that refers to procedure variable' even though, by accident, this message occurs in more constrained contexts.
Don't forget the three tests to update accordingly :-)

dkf added on 2009-01-05 16:25:09:
I suggest just getting rid of the word "upvar" from that message.

Attachments: