From: Robert Griesemer Date: Mon, 11 Mar 2013 16:16:29 +0000 (-0700) Subject: spec: result type of a comparison is always untyped bool X-Git-Tag: go1.1rc2~599 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c729ed631f1de47c7fb1fb2413b6f69be6d0f3bb;p=gostls13.git spec: result type of a comparison is always untyped bool For details see the cited issue. Fixes #4793. R=rsc, r, iant, ken CC=golang-dev https://golang.org/cl/7524044 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 5268a5b16d..992c4718a5 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -3108,7 +3108,7 @@ not occur. For instance, it may not assume that x < x + 1 is alw

Comparison operators

-Comparison operators compare two operands and yield a boolean value. +Comparison operators compare two operands and yield an untyped boolean value.

@@ -3216,20 +3216,17 @@ Comparison of pointer, channel, and interface values to nil
 is also allowed and follows from the general rules above.
 

-

-The result of a comparison can be assigned to any boolean type. -If the context does not demand a specific boolean type, -the result has type bool. -

-
-type MyBool bool
+const c = 3 < 4            // c is the untyped bool constant true
 
+type MyBool bool
 var x, y int
 var (
-	b1 MyBool = x == y // result of comparison has type MyBool
-	b2 bool   = x == y // result of comparison has type bool
-	b3        = x == y // result of comparison has type bool
+	// The result of a comparison is an untyped bool.
+	// The usual assignment rules apply.
+	b3        = x == y // b3 has type bool
+	b4 bool   = x == y // b4 has type bool
+	b5 MyBool = x == y // b5 has type MyBool
 )