From c2882b5f1594c692fb8c925e0de4b9f3d09252d5 Mon Sep 17 00:00:00 2001
From: ericm <ericm>
Date: Fri, 21 Jan 2000 03:58:16 +0000
Subject: * namespace.test: Added test for undefined variables with namespace
 which (bug #956).

* tclNamesp.c: Added check for undefined variables in
NamespaceWhichCmd (bug #956).
---
 generic/tclNamesp.c  | 5 +++--
 tests/namespace.test | 9 ++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index ea7d0cd..478867d 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -19,7 +19,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * RCS: @(#) $Id: tclNamesp.c,v 1.14 2000/01/12 11:12:53 hobbs Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.15 2000/01/21 03:58:16 ericm Exp $
  */
 
 #include "tclInt.h"
@@ -3628,7 +3628,8 @@ NamespaceWhichCmd(dummy, interp, objc, objv)
         arg = Tcl_GetString(objv[argIndex]);
 	variable = Tcl_FindNamespaceVar(interp, arg, (Tcl_Namespace *) NULL,
 		/*flags*/ 0);
-        if (variable != (Tcl_Var) NULL) {
+        if (variable != (Tcl_Var) NULL
+		&& !TclIsVarUndefined((Var *)variable)) {
             Tcl_GetVariableFullName(interp, variable, Tcl_GetObjResult(interp));
         }
         break;
diff --git a/tests/namespace.test b/tests/namespace.test
index 5843187..6cecc9e 100644
--- a/tests/namespace.test
+++ b/tests/namespace.test
@@ -11,7 +11,7 @@
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 #
-# RCS: @(#) $Id: namespace.test,v 1.7 2000/01/12 11:13:25 hobbs Exp $
+# RCS: @(#) $Id: namespace.test,v 1.8 2000/01/21 03:58:17 ericm Exp $
 
 if {[lsearch [namespace children] ::tcltest] == -1} {
     package require tcltest
@@ -1041,6 +1041,13 @@ test namespace-34.7 {NamespaceWhichCmd, variable lookup} {
              [catch {namespace which -variable ::test_ns_2::noSuchVar} msg] $msg
     }
 } {::env ::test_ns_3::v3 ::test_ns_2::v2 0 {}}
+test namespace-34.8 {NamespaceWhichCmd, lookup of undefined but traced var} {
+    catch {unset foo}
+    trace variable foo w bar
+    set res [namespace which -variable foo]
+    trace vdelete foo w bar
+    set res
+} {}
 
 test namespace-35.1 {FreeNsNameInternalRep, resulting ref count > 0} {
     catch {eval namespace delete [namespace children :: test_ns_*]}
-- 
cgit v0.12