From ef1c5357277f66d71e127e954991d4342da8c5c7 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 9 Dec 2011 00:13:19 -0500 Subject: [PATCH] spec: examples of untyped boolean, string constants This is a spec correction, not a language change. The implementations have behaved like this for years (and there are tests to that effect), and elsewhere in the spec true and false are defined to be untyped boolean constants. R=golang-dev, r CC=golang-dev https://golang.org/cl/5477047 --- doc/go_spec.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index f290b6746d..85ee436a6b 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -3408,7 +3408,7 @@ untyped complex constant yields an untyped complex constant.

A constant comparison always yields -a constant of type bool. If the left operand of a constant +an untyped boolean constant. If the left operand of a constant shift expression is an untyped constant, the result is an integer constant; otherwise it is a constant of the same type as the left operand, which must be of integer type @@ -3427,8 +3427,11 @@ const d = 1 << 3.0 // d == 8 (untyped integer constant) const e = 1.0 << 3 // e == 8 (untyped integer constant) const f = int32(1) << 33 // f == 0 (type int32) const g = float64(2) >> 1 // illegal (float64(2) is a typed floating-point constant) -const h = "foo" > "bar" // h == true (type bool) -const j = 'w' + 1 // j == 'x' (untyped character constant) +const h = "foo" > "bar" // h == true (untyped boolean constant) +const j = true // j == true (untyped boolean constant) +const k = 'w' + 1 // k == 'x' (untyped character constant) +const l = "hi" // l == "hi" (untyped string constant) +const m = string(k) // m == "x" (type string) const Σ = 1 - 0.707 // (untyped complex constant) const Δ = Σ + 2.0e-4 // (untyped complex constant) const Φ = iota*1i - 1/1i // (untyped complex constant) -- 2.48.1