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
An error message reporting that range over a type with an union constraint with multiple elements is not allowed.
What did you see instead?
./prog.go:15:20: cannot range over it (variable of type S constrained by Iterable[E]) (S has no structural type)
P.S.:
The concept of multiple underlying types used in some CL is not defined in the Type Parameter Proposal and in The Go Programming Language Specification.
Thanks.
The text was updated successfully, but these errors were encountered:
Thanks. The spec has not yet been updated. The error message is correct for what we expect to implement in 1.18. Closing because there is nothing to change here.
In the original example the type of S is either []T or []int. That means that it doesn't have a structural type. A structural type is a single type, but here there are two. It's true that they are both slices, but they are slices of different element types.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://gotipplay.golang.org/p/muzbkNYCk31
What did you expect to see?
An error message reporting that range over a type with an union constraint with multiple elements is not allowed.
What did you see instead?
P.S.:
The concept of
multiple underlying types
used in some CL is not defined in the Type Parameter Proposal and in The Go Programming Language Specification.Thanks.
The text was updated successfully, but these errors were encountered: