Skip to content

interp: implement partial type inference#1711

Open
nelsam wants to merge 2 commits into
traefik:masterfrom
nelsam:nelsam/upstream-partial-type-inference
Open

interp: implement partial type inference#1711
nelsam wants to merge 2 commits into
traefik:masterfrom
nelsam:nelsam/upstream-partial-type-inference

Conversation

@nelsam
Copy link
Copy Markdown

@nelsam nelsam commented Sep 15, 2025

Update to #1710. This solves the issue I was running into before - for some reason, it got back nil when looking up the context.Context type in the scope of a package I was trying to parse. That caused a nil pointer dereference.

I couldn't easily reproduce it in tests. When I tried to interpret similar (but simplified) code, yaegi handled it fine.

In this case, I just added logic to skip type inference for types that come back as nil - yaegi should probably leave it to some other context to error about that anyway.


Description from #1710:

When a function has multiple type parameters, it is possible to explicitly pass in some types but rely on type inference for others. For example, func Foo[T, U any](v U) T { ... } may be called with Foostring.

This implements support for partial type inference for both indexExpr and indexListExpr ast.

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.

1 participant