Skip to content

spec: direct reference to embedded fields in struct literals #9859

@adg

Description

@adg

(Status: referred from LanguageChange to Proposal. --adonovan)

Consider

type E struct {
    A int
}

type T struct {
    E
}

This works:

T{E: E{A: 1}}

This does not:

T{A: 1}

Makes some struct literals more verbose than they need be, and makes them asymmetrical to their usage (where you can access the embedded struct's fields directly).

Can we allow it?

(cc @bradfitz)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Accepted

Relationships

None yet

Development

No branches or pull requests

Issue actions