From: Matthew Dempsky Date: Tue, 1 Mar 2016 05:48:15 +0000 (-0800) Subject: go/types: nicer shift error message X-Git-Tag: go1.7beta1~1628 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8ad027c0c401a5b2d58679f8dac2b4c4f68c8ba0;p=gostls13.git go/types: nicer shift error message Updates #13940. Change-Id: I41974c292dd981d82ac03b9b8b406713445362c3 Reviewed-on: https://go-review.googlesource.com/20081 Run-TryBot: Matthew Dempsky Reviewed-by: Brad Fitzpatrick --- diff --git a/src/go/types/expr.go b/src/go/types/expr.go index f7c4a17378..4430c45d14 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -660,10 +660,10 @@ func (check *Checker) shift(x, y *operand, e *ast.BinaryExpr, op token.Token) { return } // rhs must be within reasonable bounds - const stupidShift = 1023 - 1 + 52 // so we can express smallestFloat64 + const shiftBound = 1023 - 1 + 52 // so we can express smallestFloat64 s, ok := constant.Uint64Val(yval) - if !ok || s > stupidShift { - check.invalidOp(y.pos(), "stupid shift count %s", y) + if !ok || s > shiftBound { + check.invalidOp(y.pos(), "invalid shift count %s", y) x.mode = invalid return } diff --git a/src/go/types/testdata/shifts.src b/src/go/types/testdata/shifts.src index 64865fc07b..099c9ecc7c 100644 --- a/src/go/types/testdata/shifts.src +++ b/src/go/types/testdata/shifts.src @@ -10,8 +10,8 @@ func shifts0() { s = 10 _ = 0<<0 _ = 1<> 2 _ = complex64 /* ERROR "must be integer" */ (0) << 3 _ = complex64 /* ERROR "must be integer" */ (0) >> 4 -} \ No newline at end of file +}