-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Compilation failure (cannot use struct [...] as struct [...]) #785
Comments
We have a few of these bugs, like #685, and I'm trying to figure them out. Thanks for minifying a reproducer :) |
For anyone else, the solution is to just extract the type:
This will get you building until the compatibility issue is resolved. |
I think this bug has two triggers: Anon structs: package main
import "encoding/json"
func JSON() []byte {
x := struct {
A []struct {
A int64
}
B struct {
B int64
}
}{}
x.A = append(x.A, struct{ A int64 }{A: int64(0)})
x.B = struct{ B int64 }{B: int64(0)}
b, _ := json.MarshalIndent(x, "", " ")
return b
} package main
import "encoding/json"
type ASTR struct {
A int64
}
type BSTR struct {
B int64
}
func JSON() []byte {
x := struct {
A []ASTR `json:"offsets"`
B BSTR
}{}
x.A = append(x.A, struct{ A int64 }{A: int64(0)}) // [*ssa.ChangeType ] t8 = changetype ASTR <- struct{A int64} (t5)
x.B = struct{ B int64 }{B: int64(0)} // [*ssa.ChangeType ] t16 = changetype BSTR <- struct{B int64} (t14)
b, _ := json.MarshalIndent(x, "", " ")
return b
} I think the second case can be fixed by analyzing |
Indeed that's where I'm going with a couple of local patches I've got in progress. I only got stuck since, for some reason, the behavior seems to be somewhat random. I also sent a PR to update to Go 1.21 in the meantime, and got an unexpected timeout that I can't reproduce locally 😵💫 |
What version of Garble and Go are you using?
What environment are you running Garble on?
go env
OutputWhat did you do?
Compile this code:
What did you expect to see?
What did you see instead?
Seems like only right side is garbled.
The text was updated successfully, but these errors were encountered: