diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 7f54b09071..1624858329 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -633,13 +633,13 @@ func (check *Checker) shift(x, y *operand, e *ast.BinaryExpr, op token.Token) { } // spec: "The right operand in a shift expression must have unsigned - // integer type or be an untyped constant that can be converted to - // unsigned integer type." + // integer type or be an untyped constant representable by a value of + // type uint." switch { case isUnsigned(y.typ): // nothing to do case isUntyped(y.typ): - check.convertUntyped(y, Typ[UntypedInt]) + check.convertUntyped(y, Typ[Uint]) if y.mode == invalid { x.mode = invalid return diff --git a/src/go/types/testdata/shifts.src b/src/go/types/testdata/shifts.src index 099c9ecc7c..dc029fc647 100644 --- a/src/go/types/testdata/shifts.src +++ b/src/go/types/testdata/shifts.src @@ -10,7 +10,7 @@ func shifts0() { s = 10 _ = 0<<0 _ = 1<> 1.1 /* ERROR "must be unsigned integer" */ // example from issue 11325 - _ = 0 >> 1.1 /* ERROR "must be unsigned integer" */ - _ = 0 << 1.1 /* ERROR "must be unsigned integer" */ + var _ = 0 >> 1.1 /* ERROR "truncated to uint" */ // example from issue 11325 + _ = 0 >> 1.1 /* ERROR "truncated to uint" */ + _ = 0 << 1.1 /* ERROR "truncated to uint" */ _ = 0 >> 1. - _ = 1 >> 1.1 /* ERROR "must be unsigned integer" */ + _ = 1 >> 1.1 /* ERROR "truncated to uint" */ _ = 1 >> 1. _ = 1. >> 1 _ = 1. >> 1.