]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: in compiler errors, print more digits for floats close to an int
authorKeith Randall <khr@golang.org>
Thu, 13 Oct 2022 20:30:26 +0000 (13:30 -0700)
committerKeith Randall <khr@google.com>
Thu, 20 Oct 2022 21:52:09 +0000 (21:52 +0000)
commit8415ec8c98627326ffb48141c45917b9d7d0c234
tree7cfb08cfe454e7f942df603a9ba1326e380aec65
parent160bb0e66b96e24120deba5fed927acc47b59b1a
cmd/compile: in compiler errors, print more digits for floats close to an int

Error messages currently print floats with %.6g, which means that if
you tried to convert something close to, but not quite, an integer, to
an integer, the error you get looks like "cannot convert 1 to type
int", when really you want "cannot convert 0.9999999 to type int".

Add more digits to floats when printing them, to make it clear that they
aren't quite integers. This helps for errors which are the result of not
being an integer. For other errors, it won't hurt much.

Fixes #56220

Change-Id: I7f5873af5993114a61460ef399d15316925a15a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/442935
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
src/go/constant/value.go
test/fixedbugs/issue56220.go [new file with mode: 0644]