]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: nicer shift error message
authorMatthew Dempsky <mdempsky@google.com>
Tue, 1 Mar 2016 05:48:15 +0000 (21:48 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 1 Mar 2016 06:05:49 +0000 (06:05 +0000)
Updates #13940.

Change-Id: I41974c292dd981d82ac03b9b8b406713445362c3
Reviewed-on: https://go-review.googlesource.com/20081
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/go/types/expr.go
src/go/types/testdata/shifts.src

index f7c4a173785b531a21a54e93d6e09f1611e03c76..4430c45d140fbc0cdb680f73e49b6a27f6adcf05 100644 (file)
@@ -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
                        }
index 64865fc07b9d285274067aafd767b245ef9dd26d..099c9ecc7cdc757ebc04323ae55b19295ee41dbf 100644 (file)
@@ -10,8 +10,8 @@ func shifts0() {
                s = 10
                _ = 0<<0
                _ = 1<<s
-               _ = 1<<- /* ERROR "stupid shift" */ 1
-               _ = 1<<1075 /* ERROR "stupid shift" */
+               _ = 1<<- /* ERROR "invalid shift" */ 1
+               _ = 1<<1075 /* ERROR "invalid shift" */
                _ = 2.0<<1
 
                _ int = 2<<s
@@ -338,4 +338,4 @@ func issue11594() {
        _ = float64 /* ERROR "must be integer" */ (0) >> 2
        _ = complex64 /* ERROR "must be integer" */ (0) << 3
        _ = complex64 /* ERROR "must be integer" */ (0) >> 4
-}
\ No newline at end of file
+}