diff options
-rw-r--r-- | generic/tclProc.c | 9 | ||||
-rw-r--r-- | tests/upvar.test | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c index 06ca565..ed070a3 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -695,17 +695,22 @@ TclGetFrame( result = 1; curLevel = iPtr->varFramePtr->level; if (*name== '#') { - if (Tcl_GetInt(interp, name+1, &level) != TCL_OK || level < 0) { + if (Tcl_GetInt(NULL, name+1, &level) != TCL_OK || level < 0) { goto levelError; } } else if (isdigit(UCHAR(*name))) { /* INTL: digit */ - if (Tcl_GetInt(interp, name, &level) != TCL_OK) { + if (Tcl_GetInt(NULL, name, &level) != TCL_OK) { goto levelError; } level = curLevel - level; } else { + /* + * (historical, TODO) If name does not contain a level (#0 or 1), + * TclGetFrame and Tcl_UpVar2 uses current level - 1 + */ level = curLevel - 1; result = 0; + name = "1"; /* be more consistent with TclObjGetFrame (error at top - 1) */ } /* diff --git a/tests/upvar.test b/tests/upvar.test index 908fddd..aea9333 100644 --- a/tests/upvar.test +++ b/tests/upvar.test @@ -366,7 +366,7 @@ test upvar-8.11 {upvar will not create a variable that looks like an array} -set test upvar-9.1 {Tcl_UpVar2 procedure} testupvar { list [catch {testupvar xyz a {} x global} msg] $msg -} {1 {bad level "xyz"}} +} {1 {bad level "1"}} test upvar-9.1.1 {TclGetFrame, via Tcl_UpVar2} testupvar { apply {{} {testupvar xyz a {} x local; set x foo}} set a |