-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use go-jose/go-jose
#1502
Comments
It looks like the interpreter may not be handling embedding in an unexported type. This it the
|
Struct embedding doesn't seem to work very well at the moment package main
import (
"bytes"
"reflect"
)
func main() {
tt := reflect.StructOf([]reflect.StructField{
{Name: "Buffer", Type: reflect.TypeOf(bytes.Buffer{}), Anonymous: true},
})
if _, present := tt.MethodByName("Write"); present {
println("tt has Write func")
} else {
println("tt has not Write func")
}
bt := reflect.StructOf([]reflect.StructField{
{Name: "Buffer", Type: reflect.TypeOf(&bytes.Buffer{}), Anonymous: true},
})
if _, present := bt.MethodByName("Write"); present {
println("bt has Write func")
} else {
println("bt has not Write func")
}
}
// ouput
// tt has not Write func
// bt has Write func When the field type passed into reflect.StructOf is pointer/non-pointer, the number of methods that reflect.Type can obtain is different So in Line 542 in 9d65860
Is it more reasonable to change to the following code if dest.Kind() == reflect.Interface {
if src.Kind() == reflect.Pointer {
return src.Elem().Implements(dest)
} else {
return src.Implements(dest)
}
} With this modification, the following code will work fine
But if a structure is directly embedded, and the methods of this structure all contain pointers, there is nothing can do Maybe |
@Cyb3r-Jak3 you may be interested in looking at: https://github.com/taliesins/traefik-plugin-oidc/tree/main/jwt We hacked it to work with yaegi |
@taliesins Thanks! I will take a look |
The following program
sample.go
triggers an unexpected resultExpected result
Got
Yaegi Version
v0.14.3
Additional Notes
No response
The text was updated successfully, but these errors were encountered: