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

Generic function instance types are registered in the origin package #153

Open
chriso opened this issue Jul 3, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@chriso
Copy link
Contributor

chriso commented Jul 3, 2024

We use the x/tools/go/ssa package to instantiate generics for us. We collect generic functions and their instances here, and then register type information for the runtime here.

If a package in which a generic function is instantiated refers to the package in which the generic function was defined, and the instance has a parameter that refers to a package-local type, registering function types in the origin package will cause a circular import. There's a repro here.

We either need to:

  1. register function types in a brand new package (which nothing depends on), or
  2. we need to figure out a way to register the types of generic function instances in a/the package in which the instance was created/required.

I've been digging through the SSA package to see if there's a way to do (2), but have had no luck. The *ssa.Function of generic instances has a .Pkg == nil. There don't seem to be any methods or fields that would help us determine the package (or packages) in which the instance is used.

@chriso chriso added the bug Something isn't working label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant