Skip to content

dev.go2go: generic embedded field names are not found in composite literals #44345

Closed
@griesemer

Description

@griesemer

Example:

package main

type E[T any] struct {
	A T
}

type T struct {
	E[int]
}

func main() {
	_ = T{E[int]{A: 1}}
	//_ = T{E: E[int]{A: 1}} // <<< this should work

	// manually it does work:
	var x T
	x.E = E[int]{A: 1}
}

We get an error:

./prog.go2:13: unknown field 'E' in struct literal of type T

yet when a T is set up manually, the E field is recognized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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