]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] cmd/compile: enable rational constant arithmetic
authorMatthew Dempsky <mdempsky@google.com>
Mon, 25 Jan 2021 07:39:16 +0000 (23:39 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 25 Jan 2021 18:53:24 +0000 (18:53 +0000)
commit6a4739ccc5198449d58d2e90a040c4fb908b3cb0
treedbbb2abdcc1f7d414343ec27150ebd6afb2b3955
parentbe9612a832186637173e35a2aa83ae193cf8d957
[dev.regabi] cmd/compile: enable rational constant arithmetic

This allows more precision and matches types2's behavior.

For backwards compatibility with gcimporter, for now we still need to
write out declared constants as limited-precision floating-point
values. To ensure consistent behavior of constant arithmetic whether
it spans package boundaries or not, we include the full-precision
rational representation in the compiler's extension section of the
export data.

Also, this CL simply uses the math/big.Rat.String text representation
as the encoding. This is inefficient, but because it's only in the
compiler's extension section, we can easily revisit this in the
future.

Declaring exported untyped float and complex constants isn't very
common anyway. Within the standard library, only package math declares
any at all, containing just 15. And those 15 are only imported a total
of 12 times elsewhere in the standard library.

Change-Id: I85ea23ab712e93fd3b68e52d60cbedce9be696a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/286215
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/noder/noder.go
src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/iimport.go
test/fixedbugs/issue7740.go
test/float_lit3.go