Index: generic/tclCompCmds.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompCmds.c,v
retrieving revision 1.144
diff -u -r1.144 tclCompCmds.c
--- generic/tclCompCmds.c	7 May 2008 09:07:11 -0000	1.144
+++ generic/tclCompCmds.c	26 May 2008 15:27:15 -0000
@@ -5038,10 +5038,20 @@
 	 * push its name and look it up at runtime.
 	 */
 
-	if ((envPtr->procPtr != NULL) && !hasNsQualifiers) {
-	    localIndex = TclFindCompiledLocal(name, nameChars,
-		    /*create*/ flags & TCL_CREATE_VAR,
-		    envPtr->procPtr);
+	if (!hasNsQualifiers) {
+	    Interp *iPtr = (Interp *) interp;
+
+	    if (envPtr->procPtr != NULL) {
+		localIndex = TclFindCompiledLocal(name, nameChars,
+			/*create*/ flags & TCL_CREATE_VAR,
+			envPtr->procPtr);
+	    } else if (iPtr->varFramePtr->procPtr) {
+		localIndex = TclFindCompiledLocal(name, nameChars,
+			/*create*/ 0, iPtr->varFramePtr->procPtr);
+	    } else {
+		localIndex = -1;
+	    }
+	    
 	    if ((flags & TCL_NO_LARGE_INDEX) && (localIndex > 255)) {
 		/*
 		 * We'll push the name.
@@ -5050,6 +5060,7 @@
 		localIndex = -1;
 	    }
 	}
+
 	if (localIndex < 0) {
 	    PushLiteral(envPtr, name, nameChars);
 	}
Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.371
diff -u -r1.371 tclExecute.c
--- generic/tclExecute.c	27 Apr 2008 22:21:30 -0000	1.371
+++ generic/tclExecute.c	26 May 2008 15:27:24 -0000
@@ -1463,7 +1463,18 @@
 	    }
 	}
 
-	/*
+	if (codePtr->procPtr == NULL) {
+	    /*
+	     * Check that any compiled locals do refer to the current proc
+	     * environment! If not, recompile.
+	     */
+
+	    if (codePtr->localCachePtr != iPtr->varFramePtr->localCachePtr) {
+		goto recompileObj;
+	    }
+	}
+
+        /*
 	 * Increment the code's ref count while it is being executed. If
 	 * afterwards no references to it remain, free the code.
 	 */
@@ -1493,6 +1504,10 @@
     tclByteCodeType.setFromAnyProc(interp, objPtr);
     iPtr->invokeCmdFramePtr = NULL;
     codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr;
+    if (iPtr->varFramePtr->localCachePtr) {
+	codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr;
+	codePtr->localCachePtr->refCount++;
+    }
     goto runCompiledObj;
 
     done:
Index: generic/tclProc.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclProc.c,v
retrieving revision 1.140
diff -u -r1.140 tclProc.c
--- generic/tclProc.c	27 Apr 2008 22:21:32 -0000	1.140
+++ generic/tclProc.c	26 May 2008 15:27:44 -0000
@@ -908,7 +908,7 @@
      */
 
     if (objc == 1) {
-	result = Tcl_EvalObjEx(interp, objv[0], TCL_EVAL_DIRECT);
+	result = Tcl_EvalObjEx(interp, objv[0], 0);
     } else {
 	/*
 	 * More than one argument: concatenate them together with spaces
