aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/noder.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-01-24 23:39:16 -0800
committerMatthew Dempsky <mdempsky@google.com>2021-01-25 18:53:24 +0000
commit6a4739ccc5198449d58d2e90a040c4fb908b3cb0 (patch)
treedbbb2abdcc1f7d414343ec27150ebd6afb2b3955 /src/cmd/compile/internal/noder/noder.go
parentbe9612a832186637173e35a2aa83ae193cf8d957 (diff)
downloadgo-6a4739ccc5198449d58d2e90a040c4fb908b3cb0.tar.gz
go-6a4739ccc5198449d58d2e90a040c4fb908b3cb0.zip
[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>
Diffstat (limited to 'src/cmd/compile/internal/noder/noder.go')
-rw-r--r--src/cmd/compile/internal/noder/noder.go8
1 files changed, 0 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go
index 6aab18549a..5b5b09cb2d 100644
--- a/src/cmd/compile/internal/noder/noder.go
+++ b/src/cmd/compile/internal/noder/noder.go
@@ -1455,14 +1455,6 @@ func (p *noder) basicLit(lit *syntax.BasicLit) constant.Value {
p.errorAt(lit.Pos(), "malformed constant: %s", lit.Value)
}
- // go/constant uses big.Rat by default, which is more precise, but
- // causes toolstash -cmp and some tests to fail. For now, convert
- // to big.Float to match cmd/compile's historical precision.
- // TODO(mdempsky): Remove.
- if v.Kind() == constant.Float {
- v = constant.Make(ir.BigFloat(v))
- }
-
return v
}