-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/compile: check that all n.Val() uses checked for a nil n.Type #22001
Comments
/cc @randall77 |
Change https://golang.org/cl/66450 mentions this issue: |
Very similar fix to the one made in golang.org/cl/65655. This time it's for switches on interface values, as we look for duplicates in a different manner to keep types in mind. As before, add a small regression test. Updates #22001. Fixes #22063. Change-Id: I9a55d08999aeca262ad276b4649b51848a627b02 Reviewed-on: https://go-review.googlesource.com/66450 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Change https://golang.org/cl/66690 mentions this issue: |
Continuing the discussion from https://golang.org/cl/66690, @mdempsky said:
A couple of places, one in Otherwise, all checks are either |
I'm leaning towards:
|
Sounds good. I assume that would let us get rid of either or both of the I wonder what we should do with this issue, though. Perhaps we could rewrite it to "check that none of the Val.Interface() calls can possibly panic", as that is definitely desirable as far as I can see. |
Go ahead and prepare a CL if you're interested. I think you can just put "Fixes #22001." in it. I think once we cleanup consttype that the underlying concern here has been reasonably addressed. |
Fair enough - thanks for your help :) |
Change https://golang.org/cl/69510 mentions this issue: |
If there was an error in a program related to
n
, such as the use of an undefined name to declare it, the node may be incomplete. In particular, usingn.Val()
can cause panics, as is the case ofn.Val().Interface()
.A recent example: #21988
We should check the compiler to see if there are other instances of
n.Val()
use without us checking forn.Type == nil
(orn.Type != nil
). Ideally in an automated manner, as there are more than a hundred.Val()
method calls in thegc
package.The text was updated successfully, but these errors were encountered: