Skip to content
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,debug/gosym: generics: compiler produces symbols that gosym can not parse #48032

aarzilli opened this issue Aug 28, 2021 · 3 comments


Copy link

@aarzilli aarzilli commented Aug 28, 2021

The symbol names currently produced by the compiler for generic function instantiations can not be parsed by debug/gosym (or any simple parser for that matter).

For example:

func testfunction[T any](arg T) {

func main() {

Produces the symbol main.testfunction[] for which gosym will return:

PackageName: "main"
ReceiverName: "testfunction[.shape"
BaseName: "int]"

instead of:

PackageName: "main"
ReceiverName: ""
BaseName: "testfunction[]"

Parsing symbol names is further complicated by generic method instantiations:

type S[T any] struct {
	x T

func (s *S[T]) testfunction() {

Will produce the symbol main.(*S[]).testfunction, so just looking for the first . instead of the last one doesn't work either.

Referencing issue #37762 here since its making an effort to fix a bug in this area.

@cherrymui cherrymui changed the title cmd/compile,debug/gosym: compiler produces symbols that gosym can not parse cmd/compile,debug/gosym: generics: compiler produces symbols that gosym can not parse Aug 30, 2021
Copy link

@cherrymui cherrymui commented Aug 30, 2021

cc @griesemer @randall77 @danscales

@cherrymui cherrymui added the NeedsFix label Aug 30, 2021
@cherrymui cherrymui added this to the Go1.18 milestone Aug 30, 2021
Copy link

@danscales danscales commented Aug 30, 2021

@griesemer and I talked. Once some types2 change are complete that will give a better unique name for various types (in a week or two), we will discuss gosym compatibility and other issues related to naming instantiations of generic functions/methods, and come to a more formal decision on the format of names of function instantiations.

In this case, as you describe, the '.' that we are using when specifying the type args of a function instantiation is clearly confusing the current gosym code.

Copy link

@gopherbot gopherbot commented Oct 7, 2021

Change mentions this issue: cmd/compile: adjust debug/gosym to deal with instantiated types/funcs/methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants