From 21f353c929064a6f5b7ab0395307b808ca9eef3f Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 19 Oct 2004 22:20:01 +0000 Subject: Stop losing result codes in [dict with] in some circumstances --- ChangeLog | 5 +++++ generic/tclDictObj.c | 5 ++--- tests/dict.test | 14 +++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77ad200..36caf31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-10-19 Donal K. Fellows + + * generic/tclDictObj.c (DictWithCmd): Make sure all paths (that + are not themselves error paths) do not lose the result code. + 2004-10-19 Don Porter * generic/tclInt.h (Tcl*InterpState): New internal routines diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 6d99243..57576e4 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclDictObj.c,v 1.25 2004/10/19 21:54:06 dgp Exp $ + * RCS: @(#) $Id: tclDictObj.c,v 1.26 2004/10/19 22:20:04 dkf Exp $ */ #include "tclInt.h" @@ -2975,8 +2975,7 @@ DictWithCmd(interp, objc, objv) if (allocdict) { TclDecrRefCount(dictPtr); } - TclRestoreInterpState(interp, state); - return TCL_OK; + return TclRestoreInterpState(interp, state); } } else { leafPtr = dictPtr; diff --git a/tests/dict.test b/tests/dict.test index c1004eb..f6c11d7 100644 --- a/tests/dict.test +++ b/tests/dict.test @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: dict.test,v 1.11 2004/10/08 22:44:49 dkf Exp $ +# RCS: @(#) $Id: dict.test,v 1.12 2004/10/19 22:20:05 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -1025,6 +1025,18 @@ test dict-22.9 {dict with command} { } set a } {b {c dd}} +test dict-22.10 {dict with command: result handling tricky case} { + set a {b {c d}} + foreach i {0 1} { + if {$i} break + dict with a b { + set a {} + # We're checking to see if we lose this break + break + } + } + list $i $a +} {0 {}} # cleanup ::tcltest::cleanupTests -- cgit v0.12