Skip to content

Yaegi does not properly infer types for generic functions #1610

Open
@karelorigin

Description

@karelorigin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions