Skip to content

Yaegi does not properly infer types for generic functions #1610

Open
@karelorigin

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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