You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In dwarf, the fields in anonymous struct have a package path prefix.
What did you expect to see?
I expected in dwarf for the type to have the same name as it has in pclntab and upon runtime reflection. Maybe there's a good reason for this, but it's not obvious what that might be.
The relevant change that introduced this behavior is https://go-review.googlesource.com/c/go/+/27791, and it makes sense for the compiler internals. This issue is just asking that the name that gets formatted into DWARF match that that gets used internally at reflection-time etc for consistency. In that context, there's no risk of ambiguity in that the type references are by debug info offsets. It will lead to a situation whereby multiple structure types will have the same name -- something I don't think is currently possible.
Perhaps ultimately the resolution here is "Won't Fix", but I hope this issue can serve as documentation for future folks who end up confused by the existing behavior.
Go version
go 1.23
Output of
go env
in your module/workspace:What did you do?
I observed that in DWARF, anonymous struct type names carry unexported field names with package path prefixes. See the below program:
https://go.dev/play/p/96lCdrfHAh3
The type is:
But in DWARF, the type is:
What did you see happen?
In dwarf, the fields in anonymous struct have a package path prefix.
What did you expect to see?
I expected in dwarf for the type to have the same name as it has in pclntab and upon runtime reflection. Maybe there's a good reason for this, but it's not obvious what that might be.
This has caused confusion for users of delve (go-delve/delve#1521).
The text was updated successfully, but these errors were encountered: