Skip to content

go/types, types2: bad "invalid composite literal type" error for type parameter with pointer structural type #50833

Closed
@mdempsky

Description

@mdempsky

F below is valid non-generic code, so I'd expect G to compile successfully too. However, go/types and types2 currently reject it.

package p

func F() {
        type T = *struct{ f int }
        _ = []T{{f: 1}}
}

func G[T ~*struct{ f int }]() {
        _ = []T{{f: 1}}
}

/cc @griesemer @findleyr @ianlancetaylor

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions