summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-03-01 17:55:15 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-03-01 17:55:15 (GMT)
commit0221a5309b5b2d0188aa94ea8354ec9e708ff1ea (patch)
treee551066429291dbd1232fcc21750cdbdddfaa848
parent094611c6ddb0c90a7b5419df56cb0953796fa9d4 (diff)
downloadtcl-0221a5309b5b2d0188aa94ea8354ec9e708ff1ea.zip
tcl-0221a5309b5b2d0188aa94ea8354ec9e708ff1ea.tar.gz
tcl-0221a5309b5b2d0188aa94ea8354ec9e708ff1ea.tar.bz2
* generic/tclCmdAH.c (Tcl_ForeachObjCmd): Stop throwing away
* tests/foreach.test (foreach-1.14): useful error information when loop variable sets fail.
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclCmdAH.c10
-rw-r--r--tests/foreach.test9
3 files changed, 15 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index db1ae9a..126deb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2007-03-01 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclCmdAH.c (Tcl_ForeachObjCmd): Stop throwing away
+ * tests/foreach.test (foreach-1.14): useful error information when
+ loop variable sets fail.
+
* generic/tclCmdIL.c (Tcl_LassignObjCmd): Rewrite to make an
efficient private copy of the list argument, so we can operate on the
list elements directly with no fear of shimmering effects. Replaces
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index a017a2d..3919f25 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdAH.c,v 1.84 2007/03/01 16:16:04 dgp Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.85 2007/03/01 17:55:16 dgp Exp $
*/
#include "tclInt.h"
@@ -1804,11 +1804,11 @@ Tcl_ForeachObjCmd(
valuePtr = Tcl_NewObj(); /* Empty string */
}
varValuePtr = Tcl_ObjSetVar2(interp, varvList[i][v], NULL,
- valuePtr, 0);
+ valuePtr, TCL_LEAVE_ERR_MSG);
if (varValuePtr == NULL) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "couldn't set loop variable: \"",
- TclGetString(varvList[i][v]), "\"", NULL);
+ Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
+ "\n (setting foreach loop variable \"%s\"",
+ TclGetString(varvList[i][v])));
result = TCL_ERROR;
goto done;
}
diff --git a/tests/foreach.test b/tests/foreach.test
index 8f452ed..a49ceaa 100644
--- a/tests/foreach.test
+++ b/tests/foreach.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: foreach.test,v 1.11 2007/03/01 10:07:12 dkf Exp $
+# RCS: @(#) $Id: foreach.test,v 1.12 2007/03/01 17:55:16 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -73,8 +73,11 @@ catch {unset a}
test foreach-1.14 {foreach errors} {
catch {unset a}
set a(0) 44
- list [catch {foreach a {1 2 3} {}} msg] $msg
-} {1 {couldn't set loop variable: "a"}}
+ list [catch {foreach a {1 2 3} {}} msg o] $msg $::errorInfo
+} {1 {can't set "a": variable is array} {can't set "a": variable is array
+ (setting foreach loop variable "a"
+ invoked from within
+"foreach a {1 2 3} {}"}}
test foreach-1.15 {foreach errors} {
list [catch {foreach {} {} {}} msg] $msg
} {1 {foreach varlist is empty}}