summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-09-19 14:48:02 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-09-19 14:48:02 (GMT)
commitcb5d76ed2b76f22cd7c3cf4f41ac3ef0a0f030df (patch)
treef6fcb3339905381c35a4192d4c8e95ab2bce8ed3
parent657b49a9d1d82445fd0b53afacf3077ef9d1c1eb (diff)
downloadtcl-cb5d76ed2b76f22cd7c3cf4f41ac3ef0a0f030df.zip
tcl-cb5d76ed2b76f22cd7c3cf4f41ac3ef0a0f030df.tar.gz
tcl-cb5d76ed2b76f22cd7c3cf4f41ac3ef0a0f030df.tar.bz2
Line numbers wrong in compiled [dict get].
-rw-r--r--generic/tclCompCmds.c7
-rw-r--r--tests/dict.test6
2 files changed, 9 insertions, 4 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 3445c09..efb7ff2 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -822,7 +822,7 @@ TclCompileDictGetCmd(
CompileEnv *envPtr) /* Holds resulting instructions. */
{
Tcl_Token *tokenPtr;
- int numWords, i;
+ int i;
DefineLineInformation; /* TIP #280 */
/*
@@ -834,17 +834,16 @@ TclCompileDictGetCmd(
return TCL_ERROR;
}
tokenPtr = TokenAfter(parsePtr->tokenPtr);
- numWords = parsePtr->numWords-1;
/*
* Only compile this because we need INST_DICT_GET anyway.
*/
- for (i=0 ; i<numWords ; i++) {
+ for (i=1 ; i<parsePtr->numWords ; i++) {
CompileWord(envPtr, tokenPtr, interp, i);
tokenPtr = TokenAfter(tokenPtr);
}
- TclEmitInstInt4(INST_DICT_GET, numWords-1, envPtr);
+ TclEmitInstInt4(INST_DICT_GET, parsePtr->numWords-2, envPtr);
return TCL_OK;
}
diff --git a/tests/dict.test b/tests/dict.test
index fec000d..149599b 100644
--- a/tests/dict.test
+++ b/tests/dict.test
@@ -1259,6 +1259,12 @@ test dict-23.5 {CompileWord OBOE} {
apply {{} {tcl::dict::incr foo \
[format bar]}}
} {bar 1}
+test dict-23.6 {CompileWord OBOE} {
+ apply {n {
+ dict get {a b} {*}{
+ } [return [incr n -[linenumber]]]
+ }} [linenumber]
+} 1
rename linenumber {}