diff options
author | ericm <ericm> | 2000-01-21 03:29:13 (GMT) |
---|---|---|
committer | ericm <ericm> | 2000-01-21 03:29:13 (GMT) |
commit | ac4b7b9af8a470c5eace5289a1baa2272b88d8ac (patch) | |
tree | a768d15a2696f9c09dbf4f2cee292c1b142f1363 /generic/tclVar.c | |
parent | e5a18035ecf52ade66229700d86a7c2f98253559 (diff) | |
download | tcl-ac4b7b9af8a470c5eace5289a1baa2272b88d8ac.zip tcl-ac4b7b9af8a470c5eace5289a1baa2272b88d8ac.tar.gz tcl-ac4b7b9af8a470c5eace5289a1baa2272b88d8ac.tar.bz2 |
* var.test: Added tests for corrected variable behavior (bug #981).
* upvar.n: Expanded explanation of upvar behavior with respect to
variable traces. (bugs 3917 1433 2110).
* tclVar.c: Changed behavior of variable command when name refers
to an element in an array (ie, "variable foo(x)") to always return
an error, regardless of existance of that element in the array
(now behavior is consistant with docs too) (bug #981).
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r-- | generic/tclVar.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c index 277247e..834a8dc 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclVar.c,v 1.15 2000/01/15 02:52:32 ericm Exp $ + * RCS: @(#) $Id: tclVar.c,v 1.16 2000/01/21 03:29:14 ericm Exp $ */ #include "tclInt.h" @@ -33,6 +33,7 @@ static char *danglingElement = "upvar refers to element in deleted array"; static char *danglingVar = "upvar refers to variable in deleted namespace"; static char *badNamespace = "parent namespace doesn't exist"; static char *missingName = "missing variable name"; +static char *isArrayElement = "name refers to an element in an array"; /* * Forward references to procedures defined later in this file: @@ -3854,6 +3855,16 @@ Tcl_VariableObjCmd(dummy, interp, objc, objv) varPtr = TclLookupVar(interp, varName, (char *) NULL, (TCL_NAMESPACE_ONLY | TCL_LEAVE_ERR_MSG), "define", /*createPart1*/ 1, /*createPart2*/ 0, &arrayPtr); + + if (arrayPtr != NULL) { + /* + * Variable cannot be an element in an array. If arrayPtr is + * non-null, it is, so throw up an error and return. + */ + VarErrMsg(interp, varName, NULL, "define", isArrayElement); + return TCL_ERROR; + } + if (varPtr == NULL) { return TCL_ERROR; } |