Skip to content

Commit

Permalink
interp: fix fieldName method parsing embedded + generic fields
Browse files Browse the repository at this point in the history
Fix #1571
  • Loading branch information
zbysir committed Jul 1, 2023
1 parent 75e5f99 commit c10e468
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions _test/issue-1571.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

type A struct {
*B[string]
}

type B[T any] struct {
data T
}

func main() {
_ = &A{
B: &B[string]{},
}

println("PASS")
}

// Output:
// PASS
2 changes: 2 additions & 0 deletions interp/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,8 @@ func fieldName(n *node) string {
return fieldName(n.child[1])
case starExpr:
return fieldName(n.child[0])
case indexExpr:
return fieldName(n.child[0])
case identExpr:
return n.ident
default:
Expand Down

0 comments on commit c10e468

Please sign in to comment.