traefik / yaegi

Yaegi is Another Elegant Go Interpreter
https://pkg.go.dev/github.com/traefik/yaegi
Apache License 2.0
6.78k stars 341 forks source link

Yaegi does not properly infer types for generic functions #1610

Open karelorigin opened 4 months ago

karelorigin commented 4 months ago

The following program sample.go triggers an unexpected result

package main

import "fmt"

var values = []string{
        "hello",
        "there",
}

func print[T any](v ...[]T) {
        fmt.Println(v)
}

func main() {
        print(values) // Works with: print[string](values)
}

Expected result

$ go run ./sample.go
// [[hello there]]

Got

$ yaegi ./sample.go
// run: ./sample.go:10:12: undefined type for T

Yaegi Version

da27c4f

Additional Notes

No response

karelorigin commented 1 month ago

Still an issue in v0.16.1