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

import generic functions from extracted Go code as interpreted code #1647

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

rcoreilly
Copy link
Contributor

This PR fixes issues like #1457 #1601 by importing the source code for generic functions in extracted Go code, so that it can be interpreted in yaegi.

You need to add a //yaegi:add comment directive to functions to so import, as importing all generic functions might not be desirable or feasible. In particular, given the need to interpret the generic code, it can not access any non-exported functions, types, or fields.

The extracted code is wrapped in a GenericFunc string type value as below:

 	err := i.Use(Exports{
		"guthib.com/generic/generic": map[string]reflect.Value{
			"Hello": reflect.ValueOf(GenericFunc("func Hello[T any](v T) { println(v) }")),
		},
	})

This PR builds on #1642 which interacts with this code in extracting the function source.

@rcoreilly
Copy link
Contributor Author

This and all the other PRs from me should now be good in terms of passing tests and working in our "real world" codebase which uses a lot of generics.

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

Successfully merging this pull request may close these issues.

2 participants