Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types: failure to report errors on test/fixedbugs/issue20232.go #42695

Closed
mdempsky opened this issue Nov 18, 2020 · 4 comments
Closed

go/types: failure to report errors on test/fixedbugs/issue20232.go #42695

mdempsky opened this issue Nov 18, 2020 · 4 comments
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Nov 18, 2020

While integrating go/constant into cmd/compile, I discovered that go/types isn't actually handling the test case from #20232 correctly. In particular, this variation on the test case demonstrates two latent issues:

package p

const _ uint8 = 6e5518446744
const _ = 0 * 1e+1000000000
  1. go/types fails to report any error about 6e5518446744; it should report that it's too large of a constant, or that it overflows uint8.
  2. go/types crashes on the second case, due to multiplying 0 by infinity; again, it should instead gracefully report a constant-too-large error instead.

/cc @griesemer

@findleyr findleyr self-assigned this Nov 18, 2020
@griesemer
Copy link
Contributor

There's at the very least a missing test in operand.setConst:

if x.val.Kind() == constant.Unknown {
        x.mode = invalid
}

@griesemer griesemer added this to the Go1.16 milestone Nov 18, 2020
@griesemer
Copy link
Contributor

The 2nd example is already reported as #20583.

@gopherbot
Copy link

Change https://golang.org/cl/271377 mentions this issue: go/types: report an error for invalid constant values

@gopherbot
Copy link

Change https://golang.org/cl/271520 mentions this issue: [dev.typeparams] cmd/compile/internal/types2: report an error for invalid constant values

gopherbot pushed a commit that referenced this issue Nov 19, 2020
…alid constant values

This is https://golang.org/cl/271377 ported to types2.

Updates #42695.

Change-Id: I475bdcaeace5b0e87d4476a6d660996534289666
Reviewed-on: https://go-review.googlesource.com/c/go/+/271520
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@golang golang locked and limited conversation to collaborators Nov 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants