summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-09-19 18:53:01 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-09-19 18:53:01 (GMT)
commit7b3702821be88e66474de1c1b1aa84c381276668 (patch)
treecfdbb08e5f959f29f643d207e6466edcebc494d0
parent91ec52b16e7cd903ca196560e5ddb1d5ca1c60a9 (diff)
downloadtcl-7b3702821be88e66474de1c1b1aa84c381276668.zip
tcl-7b3702821be88e66474de1c1b1aa84c381276668.tar.gz
tcl-7b3702821be88e66474de1c1b1aa84c381276668.tar.bz2
Line numbers wrong in compiled [unset].
-rw-r--r--generic/tclCompCmdsGR.c1
-rw-r--r--generic/tclCompCmdsSZ.c14
-rw-r--r--tests/var.test13
3 files changed, 21 insertions, 7 deletions
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index 4e4a3af..43ea3d3 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -587,6 +587,7 @@ TclCompileInfoCommandsCmd(
* that the result needs to be list-ified.
*/
+ /* TODO: Just push the known value */
CompileWord(envPtr, tokenPtr, interp, 1);
TclEmitOpcode( INST_RESOLVE_COMMAND, envPtr);
TclEmitOpcode( INST_DUP, envPtr);
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index d1eb9db..6c55e2e 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -2814,26 +2814,26 @@ TclCompileUnsetCmd(
CompileEnv *envPtr) /* Holds resulting instructions. */
{
Tcl_Token *varTokenPtr;
- int isScalar, localIndex, numWords, flags, i;
+ int isScalar, localIndex, flags, i;
Tcl_Obj *leadingWord;
DefineLineInformation; /* TIP #280 */
/* TODO: Consider support for compiling expanded args. */
- numWords = parsePtr->numWords-1;
flags = 1;
+ i = 1;
varTokenPtr = TokenAfter(parsePtr->tokenPtr);
leadingWord = Tcl_NewObj();
- if (numWords > 0 && TclWordKnownAtCompileTime(varTokenPtr, leadingWord)) {
+ if (parsePtr->numWords > 1 && TclWordKnownAtCompileTime(varTokenPtr, leadingWord)) {
int len;
const char *bytes = Tcl_GetStringFromObj(leadingWord, &len);
if (len == 11 && !strncmp("-nocomplain", bytes, 11)) {
flags = 0;
varTokenPtr = TokenAfter(varTokenPtr);
- numWords--;
+ i++;
} else if (len == 2 && !strncmp("--", bytes, 2)) {
varTokenPtr = TokenAfter(varTokenPtr);
- numWords--;
+ i++;
}
} else {
/*
@@ -2846,7 +2846,7 @@ TclCompileUnsetCmd(
}
TclDecrRefCount(leadingWord);
- for (i=0 ; i<numWords ; i++) {
+ for ( ; i<parsePtr->numWords ; i++) {
/*
* Decide if we can use a frame slot for the var/array name or if we
* need to emit code to compute and push the name at runtime. We use a
@@ -2856,7 +2856,7 @@ TclCompileUnsetCmd(
*/
PushVarNameWord(interp, varTokenPtr, envPtr, 0,
- &localIndex, &isScalar, 1);
+ &localIndex, &isScalar, i);
/*
* Emit instructions to unset the variable.
diff --git a/tests/var.test b/tests/var.test
index 5939100..6d4be26 100644
--- a/tests/var.test
+++ b/tests/var.test
@@ -862,6 +862,19 @@ test var-20.8 {array set compilation correctness: Bug 3603163} -setup {
}}
array size x
} -result 0
+
+test var-21.0 {PushVarNameWord OBOE in compiled unset} -setup {
+ proc linenumber {} {dict get [info frame -1] line}
+} -body {
+ apply {n {
+ set foo bar
+ unset foo {*}{
+ } [return [incr n -[linenumber]]]
+ }} [linenumber]
+} -cleanup {
+ rename linenumber {}
+} -result 1
+
catch {namespace delete ns}
catch {unset arr}