-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
"cannot use struct as struct" due to reflect detection mishandling struct literals #799
Comments
The So, tl;dr, it's improper handling of struct literals. I'll see if I can figure it out, but no promises. |
Note that there are a number of related issues, like #785 as well. |
Can you please try the latest master again? We've just merged a number of issues relating to structs and type obfuscation. |
@mvdan I tested this already with my PR, many deeply nested structs, doesn't work yet. |
Nothing changed, I get this error
|
I tried to debug this. Here is a minimal reproducer: package main
import (
"reflect"
)
func main() {}
var _ = reflect.TypeOf(Connection{})
type Connection struct {
MaxLen struct {
Varchar int
}
}
// NewConnection create a new connection from databaseURL string
func NewConnection() *Connection {
return &Connection{
MaxLen: struct {
Varchar int
}{
Varchar: 0x7FFF,
},
}
} Problem being that to go/ssa the inline struct definition doesn't exist, the value is just directly assigned to the Connection struct. For go/ast the inline struct definition is an inline struct definition without any external struct it "belongs to" I'm a bit lost here, the only "easy" solution would be to blacklist all struct fields with the same name globally (because of imports). There is probably another solution using go/ast, but I sense it will be complicated. |
Could you please show what you mean by this, perhaps with the relevant bits of the SSA statements? I'd really try to avoid going back to go/ast, or mixing it with go/ssa, because that will just bring lots of other disadvantages. If go/ssa doesn't track enough information needed to statically analyse this case, we could always raise an issue upstream. |
What version of Garble and Go are you using?
What environment are you running Garble on?
go env
OutputWhat did you do?
Can't build a package that imports github.com/sijms/go-ora/v2
Where do you think the problem originates from?
The text was updated successfully, but these errors were encountered: