-
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
Cannot run embedded + generic code #1571
Comments
Additional Note: Both of the following pieces of code work fine: type A struct {
B *B[string]
}
type B[T any] struct {
data T
}
a := &A{
B: &B[string]{},
} type A struct {
*B
}
type B struct {
}
a := &A{
B: &B{},
} |
Maybe this "embedding" issue is related to #1502 |
This can be quickly fixed by modifying the fieldName method: func fieldName(n *node) string {
switch n.kind {
case selectorExpr:
return fieldName(n.child[1])
case starExpr:
return fieldName(n.child[0])
case identExpr:
return n.ident
+ case indexExpr:
+ return fieldName(n.child[0])
default:
return ""
}
} But maybe this is not the most correct, because indexExpr seems to be the wrong kind. Update: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following program
sample.go
triggers an unexpected resultExpected result
// Nothing happend, it works fine.
Got
run: ./sample.go:13:3: unknown field b in struct literal
Yaegi Version
0.15.1
Additional Notes
Cannot run embedded + generic code, although they work in isolation.
The text was updated successfully, but these errors were encountered: