Skip to content

cmd/compile,debug/gosym: generics: compiler produces symbols that gosym can not parse #48032

@aarzilli

Description

@aarzilli

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) {
	fmt.Println(arg)
}

func main() {
	testfunction(3)
}

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

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

instead of:

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

Parsing symbol names is further complicated by generic method instantiations:

type S[T any] struct {
	x T
}

func (s *S[T]) testfunction() {
	fmt.Println(s.x)
}

Will produce the symbol main.(*S[.shape.int]).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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions