From a10b4cff91cb5d26e2049f6efc20349aa4d50d20 Mon Sep 17 00:00:00 2001
From: Robert Griesemer
-The right operand in a shift expression must have unsigned integer type
+The right operand in a shift expression must have integer type
or be an untyped constant representable by a
value of type uint
.
If the left operand of a non-constant shift expression is an untyped constant,
@@ -3586,7 +3586,9 @@ be replaced by a bitwise AND operation:
The shift operators shift the left operand by the shift count specified by the
-right operand. They implement arithmetic shifts if the left operand is a signed
+right operand, which must be positive. If the shift count is negative at run time,
+a run-time panic occurs.
+The shift operators implement arithmetic shifts if the left operand is a signed
integer and logical shifts if it is an unsigned integer.
There is no upper limit on the shift count. Shifts behave
as if the left operand is shifted n
times by 1 for a shift
@@ -5921,7 +5923,7 @@ var a = complex(2, -2) // complex128
const b = complex(1.0, -1.4) // untyped complex constant 1 - 1.4i
x := float32(math.Cos(math.Pi/2)) // float32
var c64 = complex(5, -x) // complex64
-var s uint = complex(1, 0) // untyped complex constant 1 + 0i can be converted to uint
+var s int = complex(1, 0) // untyped complex constant 1 + 0i can be converted to int
_ = complex(1, 2<<s) // illegal: 2 assumes floating-point type, cannot shift
var rl = real(c64) // float32
var im = imag(a) // float64
--
2.50.0