-
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
x/tools/go/ssa: ent.withHooks$1: cannot convert *t0 (M) to PM #58633
Comments
@golang/tools-team |
any workaround ? |
You could make the following change to the analyzed code in golangci-vs-ent-generics/ent/ent.go:
|
This comment was marked as outdated.
This comment was marked as outdated.
Ah, you also need to have run "go get golang.org/x/tools@master" in the golangci-lint module and rebuilt the tool, since that picks up a fix that allows the workaround to work. (I had done that step, which was not sufficient by itself, and then forgotten that it enabled the workaround.) I admit it is inconvenient that both the tool and the analyzed code must be adjusted, but it is a workaround. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Yes, recently it has become an automated monthly process. |
QQ » does that make it March or April? (Organising tasks) |
Related to #57272 |
@adonovan, hello! I cannot explain why 🤦 , but when I tested locally your workaround (several times) it worked. But in official build it doesn't work for some reason. I wrote a test based on example above and it really doesn't pass on the TestGenericBodies (sorry, I tried simpler variants but they passed)// go/ssa/builder_generic_test.go
// ...
{
pkg: "k",
contents: `
package k
type Value any
type Mutation interface { Type() string }
type Mutator interface { Mutate(Mutation) (Value, error)}
type Hook func(Mutator) Mutator
type MutateFunc func(Mutation) (Value, error)
func (f MutateFunc) Mutate(m Mutation) (Value, error) { return f(m) }
func withHooks[V Value, M any, PM interface {
*M
Mutation
}](exec func() (V, error), mutation PM, hooks []Hook) (value V, err error) {
var mut Mutator = MutateFunc(func(m Mutation) (Value, error) {
m1 := *(m.(PM))
m2 := *(any(m).(PM))
print(m1) /*@ types(M)*/
print(m2) /*@ types(M)*/
*mutation, *mutation = m1, m2
return exec()
})
for i := len(hooks) - 1; i >= 0; i-- {
mut = hooks[i](mut)
}
v, _ := mut.Mutate(mutation)
nv, _ := v.(V)
return nv, nil
}
`,
},
I do not exclude that I am doing something wrong, or my local environment has generated some side effects. I will try to find the cause of the panic, or I hope the test above will help Golang team do this. |
Change https://go.dev/cl/477635 mentions this issue: |
This is now affecting govulncheck (x/vuln) as well, as of v0.1.0, despite it using a recent x/tools commit from I attempted to bisect what commit introduced the problem there, and came up with golang/vuln@4fb01e0, but the nature of that commit makes me suspicious of my testing. |
Change https://go.dev/cl/492598 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, and it's actual for
x/tools
master too.What did you do?
Demo: https://github.com/Antonboom/golangci-vs-ent-generics
What did you expect to see?
No panics.
What did you see instead?
Full stack trace
Additional info
Related to bodyclose: panic "interface conversion: interface {} is nil, not *buildssa.SSA" golangci/golangci-lint#3086
Suggested problematic code:
The text was updated successfully, but these errors were encountered: