summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclCompCmds.c9
-rw-r--r--tests/dict.test9
3 files changed, 17 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ac9644..814edac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2008-03-16 Donal K. Fellows <dkf@users.sf.net>
+ * generic/tclCompCmds.c (TclCompileDictForCmd): Correct the handling
+ of stack space calculation (the jump pattern used was confusing the
+ simple-minded code doing the calculations). [Bug 1903325]
+
* doc/lreplace.n: Clarified documentation of what happens with
negative indices. [Bug 1905809] Added example, tidied up formatting.
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index da97f08..9fa3bf6 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmds.c,v 1.142 2008/02/28 15:59:34 dgp Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.143 2008/03/16 17:00:43 dkf Exp $
*/
#include "tclInt.h"
@@ -814,7 +814,9 @@ TclCompileDictForCmd(
int keyVarIndex, valueVarIndex, nameChars, loopRange, catchRange;
int infoIndex, jumpDisplacement, bodyTargetOffset, emptyTargetOffset;
int numVars, endTargetOffset;
- int savedStackDepth = envPtr->currStackDepth; /* is this necessary? */
+ int savedStackDepth = envPtr->currStackDepth;
+ /* Needed because jumps confuse the stack
+ * space calculator. */
const char **argv;
Tcl_DString buffer;
@@ -921,9 +923,7 @@ TclCompileDictForCmd(
envPtr->line = mapPtr->loc[eclIndex].line[4];
CompileBody(envPtr, bodyTokenPtr, interp);
- envPtr->currStackDepth = savedStackDepth + 1;
TclEmitOpcode( INST_POP, envPtr);
- envPtr->currStackDepth = savedStackDepth;
/*
* Both exception target ranges (error and loop) end here.
@@ -977,6 +977,7 @@ TclCompileDictForCmd(
* easy!) Note that we skip the END_CATCH. [Bug 1382528]
*/
+ envPtr->currStackDepth = savedStackDepth+2;
jumpDisplacement = CurrentOffset(envPtr) - emptyTargetOffset;
TclUpdateInstInt4AtPc(INST_JUMP_TRUE4, jumpDisplacement,
envPtr->codeStart + emptyTargetOffset);
diff --git a/tests/dict.test b/tests/dict.test
index 6f4ea3c..ce51633 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.23 2007/12/13 15:26:06 dgp Exp $
+# RCS: @(#) $Id: dict.test,v 1.24 2008/03/16 17:00:44 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -562,6 +562,13 @@ test dict-14.18 {dict for command in compilation context} {
test dict-14.19 {dict for and invalid dicts: bug 1531184} -body {
di[list]ct for {k v} x {}
} -returnCodes 1 -result {missing value to go with key}
+test dict-14.20 {dict for stack space compilation: bug 1903325} {
+ proc dicttest {x y args} {
+ dict for {a b} $x {}
+ concat "c=$y,$args"
+ }
+ dicttest {} 1 2 3
+} {c=1,2 3}
# There's probably a lot more tests to add here. Really ought to use a
# coverage tool for this job...