Index: doc/incr.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/incr.n,v
retrieving revision 1.5
diff -u -r1.5 incr.n
--- doc/incr.n	27 Oct 2004 12:53:22 -0000	1.5
+++ doc/incr.n	9 Feb 2006 17:23:55 -0000
@@ -20,12 +20,18 @@
 .SH DESCRIPTION
 .PP
 Increments the value stored in the variable whose name is \fIvarName\fR.
-The value of the variable must be an integer.
+The value of the variable must be an integer.  
 If \fIincrement\fR is supplied then its value (which must be an
 integer) is added to the value of variable \fIvarName\fR;  otherwise
 1 is added to \fIvarName\fR.
 The new value is stored as a decimal string in variable \fIvarName\fR
 and also returned as result.
+.PP
+.VS 8.5
+Starting with the Tcl 8.5 release, the variable \fIvarName\fR passed
+to \fBincr\fR may be unset, and in that case, it will be set to
+the value \fIincrement\fR or to the default increment value of \fB1\fR.
+.VE 8.5
 .SH EXAMPLES
 Add one to the contents of the variable \fIx\fR:
 .CS
@@ -44,7 +50,7 @@
 .CE
 .PP
 Add nothing at all to the variable \fIx\fR (often useful for checking
-whether an argument to a procedure is actually numeric and generating
+whether an argument to a procedure is actually integral and generating
 an error if it is not):
 .CS
 \fBincr\fR x 0
Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.225
diff -u -r1.225 tclExecute.c
--- generic/tclExecute.c	27 Dec 2005 20:14:08 -0000	1.225
+++ generic/tclExecute.c	9 Feb 2006 17:23:56 -0000
@@ -2403,7 +2403,7 @@
 	part1 = TclGetString(objPtr);
 
 	varPtr = TclObjLookupVar(interp, objPtr, part2,
-		TCL_LEAVE_ERR_MSG, "read", 0, 1, &arrayPtr);
+		TCL_LEAVE_ERR_MSG, "read", 1, 1, &arrayPtr);
 	if (varPtr == NULL) {
 	    Tcl_AddObjErrorInfo(interp,
 		    "\n    (reading value of variable to increment)", -1);
Index: generic/tclVar.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclVar.c,v
retrieving revision 1.119
diff -u -r1.119 tclVar.c
--- generic/tclVar.c	2 Feb 2006 10:55:05 -0000	1.119
+++ generic/tclVar.c	9 Feb 2006 17:23:56 -0000
@@ -1780,7 +1780,7 @@
     part2 = ((part2Ptr == NULL)? NULL : TclGetString(part2Ptr));
 
     varPtr = TclObjLookupVar(interp, part1Ptr, part2, flags, "read",
-	    0, 1, &arrayPtr);
+	    1, 1, &arrayPtr);
     if (varPtr == NULL) {
 	Tcl_AddObjErrorInfo(interp,
 		"\n    (reading value of variable to increment)", -1);
@@ -1839,11 +1839,11 @@
     register Tcl_Obj *varValuePtr, *newValuePtr = NULL;
     int duplicated, code;
 
+    varPtr->refCount++;
     varValuePtr = TclPtrGetVar(interp, varPtr, arrayPtr, part1, part2, flags);
+    varPtr->refCount--;
     if (varValuePtr == NULL) {
-	Tcl_AddObjErrorInfo(interp,
-		"\n    (reading value of variable to increment)", -1);
-	return NULL;
+	varValuePtr = Tcl_NewIntObj(0);
     }
     if (Tcl_IsShared(varValuePtr)) {
 	duplicated = 1;
Index: tests/compile.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/compile.test,v
retrieving revision 1.40
diff -u -r1.40 compile.test
--- tests/compile.test	9 Nov 2005 20:24:10 -0000	1.40
+++ tests/compile.test	9 Feb 2006 17:23:58 -0000
@@ -250,13 +250,13 @@
     list [catch {p} msg] $msg
 } {1 {list must have an even number of elements}}
 test compile-11.5 {Tcl_Append*: ensure Tcl_ResetResult is used properly} {
-    proc p {} { set r [list foobar] ; incr foo }
+    proc p {} { set r [list foobar] ; incr foo bar baz}
     list [catch {p} msg] $msg
-} {1 {can't read "foo": no such variable}}
+} {1 {wrong # args: should be "incr varName ?increment?"}}
 test compile-11.6 {Tcl_Append*: ensure Tcl_ResetResult is used properly} {
-    proc p {} { set r [list foobar] ; incr foo bogus }
+    proc p {} { set r [list foobar] ; incr}
     list [catch {p} msg] $msg
-} {1 {can't read "foo": no such variable}}
+} {1 {wrong # args: should be "incr varName ?increment?"}}
 test compile-11.7 {Tcl_Append*: ensure Tcl_ResetResult is used properly} -body {
     proc p {} { set r [list foobar] ; expr !a }
     list [catch {p} msg] $msg
Index: tests/incr-old.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/incr-old.test,v
retrieving revision 1.8
diff -u -r1.8 incr-old.test
--- tests/incr-old.test	3 Nov 2004 17:16:05 -0000	1.8
+++ tests/incr-old.test	9 Feb 2006 17:23:58 -0000
@@ -47,11 +47,8 @@
 } {1 {wrong # args: should be "incr varName ?increment?"}}
 test incr-old-2.3 {incr errors} {
     catch {unset x}
-    list [catch {incr x} msg] $msg $errorInfo
-} {1 {can't read "x": no such variable} {can't read "x": no such variable
-    (reading value of variable to increment)
-    invoked from within
-"incr x"}}
+    incr x
+} 1
 test incr-old-2.4 {incr errors} {
     set x abc
     list [catch {incr x} msg] $msg $errorInfo
Index: tests/incr.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/incr.test,v
retrieving revision 1.11
diff -u -r1.11 incr.test
--- tests/incr.test	3 Nov 2004 17:16:05 -0000	1.11
+++ tests/incr.test	9 Feb 2006 17:23:58 -0000
@@ -87,9 +87,8 @@
     proc p {} {
         incr bar
     }
-    catch {p} msg
-    set msg
-} {can't read "bar": no such variable}
+    p
+} 1
 test incr-1.14 {TclCompileIncrCmd: simple local name, >255 locals} {
     proc 260locals {} {
         # create 260 locals
@@ -211,11 +210,9 @@
 
 
 test incr-1.26 {TclCompileIncrCmd: runtime error, bad variable name} {
-    list [catch {incr {"foo}} msg] $msg $errorInfo
-} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
-    (reading value of variable to increment)
-    invoked from within
-"incr {"foo}"}}
+    unset -nocomplain {"foo}
+    incr {"foo}
+} 1
 test incr-1.27 {TclCompileIncrCmd: runtime error, bad variable name} -body {
     list [catch {incr [set]} msg] $msg $errorInfo
 } -match glob -result {1 {wrong # args: should be "set varName ?newValue?"} {wrong # args: should be "set varName ?newValue?"
@@ -331,9 +328,8 @@
 	set z incr
         $z bar
     }
-    catch {p} msg
-    set msg
-} {can't read "bar": no such variable}
+    p
+} 1
 test incr-2.14 {incr command (not compiled): simple local name, >255 locals} {
    proc 260locals {} {
         set z incr
@@ -467,12 +463,10 @@
 
 
 test incr-2.26 {incr command (not compiled): runtime error, bad variable name} {
+    unset -nocomplain {"foo}
     set z incr
-    list [catch {$z {"foo}} msg] $msg $errorInfo
-} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
-    (reading value of variable to increment)
-    invoked from within
-"$z {"foo}"}}
+    $z {"foo}
+} 1
 test incr-2.27 {incr command (not compiled): runtime error, bad variable name} -body {
     set z incr
     list [catch {$z [set]} msg] $msg $errorInfo
Index: tests/set.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/set.test,v
retrieving revision 1.9
diff -u -r1.9 set.test
--- tests/set.test	3 Nov 2004 17:16:05 -0000	1.9
+++ tests/set.test	9 Feb 2006 17:23:58 -0000
@@ -233,6 +233,7 @@
 {b c} foo 51}]; # " just a matching end quote
 
 test set-2.1 {set command: runtime error, bad variable name} {
+    unset -nocomplain {"foo}
     list [catch {set {"foo}} msg] $msg $errorInfo
 } {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
     while executing
@@ -476,6 +477,7 @@
 } {wrong # args: should be "set varName ?newValue?"}
 
 test set-4.1 {uncompiled set command: runtime error, bad variable name} {
+    unset -nocomplain {"foo}
     set z set
     list [catch {$z {"foo}} msg] $msg $errorInfo
 } {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
