aboutsummaryrefslogtreecommitdiff
path: root/test/const1.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2019-03-27 12:15:47 -0700
committerMatthew Dempsky <mdempsky@google.com>2019-03-28 17:46:55 +0000
commit9f6b21caeaba3362f3385e635054f94d7f0499f3 (patch)
treeba4b73173487d7bc91f7b1dc896640249dd1487f /test/const1.go
parentc1e60b6e336dba3820cb27442cec33d15b2a5f7d (diff)
downloadgo-9f6b21caeaba3362f3385e635054f94d7f0499f3.tar.gz
go-9f6b21caeaba3362f3385e635054f94d7f0499f3.zip
cmd/compile: fix ICE from invalid operations on float/complex constants
Typechecking treats all untyped numbers as integers for the purposes of validating operators. However, when I refactoring constant operation evalution in golang.org/cl/139901, I mistakenly interpreted that the only invalid case that needed to be preserved was % (modulo) on floating-point values. This CL restores the other remaining cases that were dropped from that CL. It also uses the phrasing "invalid operation" instead of "illegal constant expression" for better consistency with the rest of cmd/compile and with go/types. Lastly, this CL extends setconst to recognize failed constant folding (e.g., division by zero) so that we can properly mark those expressions as broken rather than continuing forward with bogus values that might lead to further spurious errors. Fixes #31060. Change-Id: I1ab6491371925e22bc8b95649f1a0eed010abca6 Reviewed-on: https://go-review.googlesource.com/c/go/+/169719 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'test/const1.go')
-rw-r--r--test/const1.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/const1.go b/test/const1.go
index 62abe4145a..3fd5b55522 100644
--- a/test/const1.go
+++ b/test/const1.go
@@ -68,7 +68,7 @@ var (
c3 float64 = float64(Big) * Big // ERROR "overflow"
c4 = Big * Big // ERROR "overflow"
c5 = Big / 0 // ERROR "division by zero"
- c6 = 1000 % 1e3 // ERROR "floating-point % operation|expected integer type"
+ c6 = 1000 % 1e3 // ERROR "invalid operation|expected integer type"
)
func f(int)