aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/expr.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-03-18 17:29:02 -0700
committerRobert Griesemer <gri@golang.org>2021-03-23 05:12:12 +0000
commitcd26192abab742cb2df24827226eab0e9f3683a9 (patch)
treeaf0a0fcb15dcfe6cb1b149d59fb17cbe82535076 /src/go/types/expr.go
parente7aa0f9f2834fb7eac1f435f834e6bbf461d55ac (diff)
downloadgo-cd26192abab742cb2df24827226eab0e9f3683a9.tar.gz
go-cd26192abab742cb2df24827226eab0e9f3683a9.zip
go/types: remove superfluous code for shift checking
Negative constant shift counts are already handled earlier in the code. No need anymore for this extra section. With this change, the shift code matches types2 with respect to the function logic. Change-Id: Ic8b7f382271c79ab66021e30955cd9bac092332b Reviewed-on: https://go-review.googlesource.com/c/go/+/303093 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/go/types/expr.go')
-rw-r--r--src/go/types/expr.go16
1 files changed, 1 insertions, 15 deletions
diff --git a/src/go/types/expr.go b/src/go/types/expr.go
index e1b484c410..170761afb3 100644
--- a/src/go/types/expr.go
+++ b/src/go/types/expr.go
@@ -805,20 +805,6 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
return
}
- var yval constant.Value
- if y.mode == constant_ {
- // rhs must be an integer value
- // (Either it was of an integer type already, or it was
- // untyped and successfully converted to a uint above.)
- yval = constant.ToInt(y.val)
- assert(yval.Kind() == constant.Int)
- if constant.Sign(yval) < 0 {
- check.invalidOp(y, _InvalidShiftCount, "negative shift count %s", y)
- x.mode = invalid
- return
- }
- }
-
if x.mode == constant_ {
if y.mode == constant_ {
// if either x or y has an unknown value, the result is unknown
@@ -832,7 +818,7 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
}
// rhs must be within reasonable bounds in constant shifts
const shiftBound = 1023 - 1 + 52 // so we can express smallestFloat64 (see issue #44057)
- s, ok := constant.Uint64Val(yval)
+ s, ok := constant.Uint64Val(y.val)
if !ok || s > shiftBound {
check.invalidOp(y, _InvalidShiftCount, "invalid shift count %s", y)
x.mode = invalid