diff options
| author | Robert Griesemer <gri@golang.org> | 2023-05-08 14:46:17 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-05-08 22:07:01 +0000 |
| commit | f3247f6110d41793b0fc1c1a9d6541e649acd438 (patch) | |
| tree | ce2db0f891cc423cafa13bc39fef9d0a0c449521 | |
| parent | 0a9875c5c809fa70ae6662b8a38f5f86f648badd (diff) | |
| download | go-f3247f6110d41793b0fc1c1a9d6541e649acd438.tar.xz | |
cmd/compile/internal/types2: pass pos argument to Checker.overflow
This matches the go/types version of Checker.overflow.
Preparation for generating this function (and others)
for go/types.
Change-Id: I84117203247011bd2e96c9cf53fd5a443e528bbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/493558
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
| -rw-r--r-- | src/cmd/compile/internal/types2/expr.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 93ca24addc..4dc46d4a48 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -87,14 +87,14 @@ func (check *Checker) op(m opPredicates, x *operand, op syntax.Operator) bool { // overflow checks that the constant x is representable by its type. // For untyped constants, it checks that the value doesn't become // arbitrarily large. -func (check *Checker) overflow(x *operand) { +func (check *Checker) overflow(x *operand, pos syntax.Pos) { assert(x.mode == constant_) if x.val.Kind() == constant.Unknown { // TODO(gri) We should report exactly what went wrong. At the // moment we don't have the (go/constant) API for that. // See also TODO in go/constant/value.go. - check.error(opPos(x.expr), InvalidConstVal, "constant result is not representable") + check.error(pos, InvalidConstVal, "constant result is not representable") return } @@ -114,7 +114,7 @@ func (check *Checker) overflow(x *operand) { if op != "" { op += " " } - check.errorf(opPos(x.expr), InvalidConstVal, "constant %soverflow", op) + check.errorf(pos, InvalidConstVal, "constant %soverflow", op) x.val = constant.MakeUnknown() } } @@ -242,7 +242,7 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) { } x.val = constant.UnaryOp(op2tok[op], x.val, prec) x.expr = e - check.overflow(x) + check.overflow(x, opPos(x.expr)) return } @@ -1020,7 +1020,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { // x is a constant so xval != nil and it must be of Int kind. x.val = constant.Shift(xval, op2tok[op], uint(s)) x.expr = e - check.overflow(x) + check.overflow(x, opPos(x.expr)) return } @@ -1221,7 +1221,7 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op } x.val = constant.BinaryOp(x.val, tok, y.val) x.expr = e - check.overflow(x) + check.overflow(x, opPos(x.expr)) return } @@ -1360,7 +1360,7 @@ func (check *Checker) exprInternal(T Type, x *operand, e syntax.Expr, hint Type) } // Ensure that integer values don't overflow (go.dev/issue/54280). x.expr = e // make sure that check.overflow below has an error position - check.overflow(x) + check.overflow(x, opPos(x.expr)) case *syntax.FuncLit: if sig, ok := check.typ(e.Type).(*Signature); ok { |
