You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe this is not yet fully documented in the in-progress spec. But here it is: type parameters cannot be constant types. While 5 can be stored in a variable of type P, it cannot be the value of a constant of type P. Specifically, and this is documented in the section on conversions, if a constant is converted to a type parameter, say P(5), the result is a non-constant value.
The compilation of the following program fails with error
./prog.go:4:10: invalid constant type P
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.
The text was updated successfully, but these errors were encountered: