summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2001-08-10 13:10:13 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2001-08-10 13:10:13 (GMT)
commite3e4bcea9c4105e94029baa9f8c5ddad79fdc692 (patch)
treec9e4138fcbb2e69dcb5e9e7dcf03f049e2cca084 /generic/tclVar.c
parenta824d7b8087eb9e6024ad460b982386fe419faea (diff)
downloadtcl-e3e4bcea9c4105e94029baa9f8c5ddad79fdc692.zip
tcl-e3e4bcea9c4105e94029baa9f8c5ddad79fdc692.tar.gz
tcl-e3e4bcea9c4105e94029baa9f8c5ddad79fdc692.tar.bz2
insure that [array] traces work for undefined vars [bug: 449094]
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index ba76f00..c342522 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.35 2001/07/04 00:55:08 hobbs Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.36 2001/08/10 13:10:13 msofer Exp $
*/
#include "tclInt.h"
@@ -3061,19 +3061,13 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
}
/*
- * Locate the array variable (and it better be an array).
+ * Locate the array variable
*/
varName = TclGetString(objv[2]);
varPtr = TclLookupVar(interp, varName, (char *) NULL, /*flags*/ 0,
/*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr);
- notArray = 0;
- if ((varPtr == NULL) || !TclIsVarArray(varPtr)
- || TclIsVarUndefined(varPtr)) {
- notArray = 1;
- }
-
/*
* Special array trace used to keep the env array in sync for
* array names, array get, etc.
@@ -3091,6 +3085,18 @@ Tcl_ArrayObjCmd(dummy, interp, objc, objv)
}
/*
+ * Verify that it is indeed an array variable. This test comes after
+ * the traces - the variable may actually become an array as an effect
+ * of said traces.
+ */
+
+ notArray = 0;
+ if ((varPtr == NULL) || !TclIsVarArray(varPtr)
+ || TclIsVarUndefined(varPtr)) {
+ notArray = 1;
+ }
+
+ /*
* We have to wait to get the resultPtr until here because
* CallTraces can affect the result.
*/