The following program sample.go triggers an unexpected result
package main
import (
"fmt"
)
func SomeFunc[T int | string](defaultValue T) T {
switch v := any(&defaultValue).(type) {
case *string:
*v = *v + " abc"
case *int:
*v -= 234
}
return defaultValue
}
func main() {
fmt.Println(SomeFunc("test"))
fmt.Println(SomeFunc(1234))
}
Expected result
test abc
1000
Got
main.go:8:2: panic
main.go:18:2: panic
run: interface conversion: interface {} is *string, not interp.valueInterface
Yaegi Version
0.14.2
Additional Notes
I stumbled on this error while I was creating some bridge wrappers for some external generic methods.
Could reduce it to this example, hope someone can help me solve this one. As i do have a hard time understanding the internals of the interpreter that doing the cast at some point
The following program
sample.go
triggers an unexpected resultExpected result
Got
Yaegi Version
0.14.2
Additional Notes
I stumbled on this error while I was creating some bridge wrappers for some external generic methods.
Could reduce it to this example, hope someone can help me solve this one. As i do have a hard time understanding the internals of the interpreter that doing the cast at some point
/github.com/traefik/yaegi@v0.14.2/interp/run.go:2999