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
As I already said, according to this linked article description, the compilation should prompt an error. Then this URL I have also written in the issue.
No, there should not be an error, even according to the linked article. Note that in
func (sMySlice[string]) Sum() string { ...
MySlice is a a slice of strings, but here the name string does not mean the predeclared type string. It is the name (which happens to be string) of the type parameter declared through MySlice[string]. The important point here is that this receiver is a declaration of a local (i.e., for this method) name for the type parameter T in the struct.
As has been pointed out before, this is working as intended.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
According to the https://go.dev/doc/faq#types_in_method_declaration I should see compilation errors
What did you see instead?
float32 16.5
The text was updated successfully, but these errors were encountered: