]> Cypherpunks repositories - gostls13.git/commit
[dev.typeparams] cmd/compile/internal/types2: handle untyped constant arithmetic...
authorRobert Griesemer <gri@golang.org>
Thu, 28 Jan 2021 22:29:25 +0000 (14:29 -0800)
committerRobert Griesemer <gri@golang.org>
Sat, 30 Jan 2021 00:36:53 +0000 (00:36 +0000)
commita59cb5109d49ac0dc09337449b9c7760ecc66c0e
tree02ca11cbef50e9b41ab1448a68810e2014284841
parent507e641963c6e4277ae4bc9d5f44469d2b4c9c8f
[dev.typeparams] cmd/compile/internal/types2: handle untyped constant arithmetic overflow

Factor out the existing "constant representation" check after
untyped constant arithmetic and combine with an overflow check.

Use a better heuristic for determining the error position if we
know the error is for a constant operand that is the result of an
arithmetic expression.

Related cleanups.

With this change, untyped constant arithmetic reports an error
when (integer) constants become too large (> 2048 bits). Before,
such arithmetic was only limited by space and time.

Change-Id: Id3cea66c8ba697ff4c7fd1e848f350d9713e3c75
Reviewed-on: https://go-review.googlesource.com/c/go/+/287832
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/fixedbugs/issue20583.src
src/cmd/compile/internal/types2/stdlib_test.go
src/cmd/compile/internal/types2/stmt.go
src/cmd/compile/internal/types2/testdata/const0.src
test/run.go