Skip to content

spec: EBNF for struct types does not permit embedding instantiated types #53240

@dominikh

Description

@dominikh

https://tip.golang.org/ref/spec#Struct_types defines

EmbeddedField = [ "*" ] TypeName .

with

TypeName  = identifier | QualifiedIdent .
QualifiedIdent = PackageName "." identifier .

if I am not mistaken, that doesn't permit the following valid program:


type S1[T any] struct{ F T }
type S2 struct{ S1[int] }

func main() { fmt.Println(S2{}.F) }

(https://go.dev/play/p/ZmKJ9hWyhOZ)

/cc @griesemer

Edit: LiteralType seems to have a similar issue for composite literals, via https://groups.google.com/g/golang-nuts/c/W_kqb9rfT5c

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions