From 8ad027c0c401a5b2d58679f8dac2b4c4f68c8ba0 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 29 Feb 2016 21:48:15 -0800 Subject: [PATCH] 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 --- src/go/types/expr.go | 6 +++--- src/go/types/testdata/shifts.src | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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 +} -- 2.50.0