yaegi icon indicating copy to clipboard operation
yaegi copied to clipboard

Yaegi does not properly infer types for generic functions

Open karelorigin opened this issue 4 months ago • 1 comments

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 avatar Feb 24 '24 14:02 karelorigin