summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclCompCmds.c8
-rw-r--r--tests/upvar.test21
2 files changed, 25 insertions, 4 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 6189b29..8e26a30 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -5920,7 +5920,7 @@ TclCompileNamespaceCmd(
*/
tokenPtr = TokenAfter(tokenPtr);
- CompileWord(envPtr, tokenPtr, interp, 1);
+ CompileWord(envPtr, tokenPtr, interp, 2);
/*
* Loop over the (otherVar, thisVar) pairs. If any of the thisVar is not a
@@ -5929,13 +5929,13 @@ TclCompileNamespaceCmd(
*/
localTokenPtr = tokenPtr;
- for(i=4; i<=numWords; i+=2) {
+ for(i=3; i<numWords; i+=2) {
otherTokenPtr = TokenAfter(localTokenPtr);
localTokenPtr = TokenAfter(otherTokenPtr);
- CompileWord(envPtr, otherTokenPtr, interp, 1);
+ CompileWord(envPtr, otherTokenPtr, interp, i);
PushVarNameWord(interp, localTokenPtr, envPtr, TCL_CREATE_VAR,
- &localIndex, &simpleVarName, &isScalar, 1);
+ &localIndex, &simpleVarName, &isScalar, i+1);
if((localIndex < 0) || !isScalar) {
return TCL_ERROR;
diff --git a/tests/upvar.test b/tests/upvar.test
index d88d2c9..df7f551 100644
--- a/tests/upvar.test
+++ b/tests/upvar.test
@@ -553,6 +553,27 @@ test upvar-NS-1.9 {nsupvar links to correct variable} \
-returnCodes error \
-cleanup {namespace delete test_ns_1}
+test upvar-NS-2.1 {CompileWord OBOE} -setup {
+ proc linenumber {} {dict get [info frame -1] line}
+} -body {
+ apply {n {
+ namespace upvar {*}{
+ } [return [incr n -[linenumber]]] x y
+ }} [linenumber]
+} -cleanup {
+ rename linenumber {}
+} -result 1
+test upvar-NS-2.2 {CompileWord OBOE} -setup {
+ proc linenumber {} {dict get [info frame -1] line}
+} -body {
+ apply {n {
+ namespace upvar :: {*}{
+ } [return [incr n -[linenumber]]] x
+ }} [linenumber]
+} -cleanup {
+ rename linenumber {}
+} -result 1
+
# cleanup
::tcltest::cleanupTests