Attachment "arrayTrace.txt" to
ticket [449094ffff]
added by
msofer
2001-08-10 20:12:36.
? arrayTrace.txt
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.517
diff -r1.517 ChangeLog
0a1,6
> 2001-08-10 Miguel Sofer <[email protected]>
>
> * generic/tclVar.c:
> * tests/trace.test: Insure that [array] traces work correctly for
> undefined variables [Bug: 449094]
>
Index: generic/tclVar.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclVar.c,v
retrieving revision 1.35
diff -r1.35 tclVar.c
3064c3064
< * Locate the array variable (and it better be an array).
---
> * Locate the array variable
3071,3076d3070
< notArray = 0;
< if ((varPtr == NULL) || !TclIsVarArray(varPtr)
< || TclIsVarUndefined(varPtr)) {
< notArray = 1;
< }
<
3090a3085,3096
> }
>
> /*
> * 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;
Index: tests/trace.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/trace.test,v
retrieving revision 1.9
diff -r1.9 trace.test
338a339,343
> test trace-5.8 {array traces fire for undefined variables} {
> catch {unset x}
> trace add variable x array {set x(foo) 1 ;#}
> set res "names: [array names x]"
> } {names: foo}