Skip to content

spec: document that type parameters are not permitted as constant declaration types #50202

@gazerro

Description

@gazerro

The compilation of the following program fails with error ./prog.go:4:10: invalid constant type P

package main

func f[P int]() {
	const y P = 5
}

func main() {}

but this behavior is not documented in the spec.

From the spec 5 is assignable to P because it is an untyped constant representable by a value of type P.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions