Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
spec: Document rules for recursive type and other self-referential decls #5069
The spec says "An interface type T may not embed itself or any interface type that embeds T, recursively.", but nothing like this is mentioned for structs. (A struct containing itself would obviously need infty memory, but the spec should probably still explicitly mention that these are illegal while a struct containing a pointer to itself is fine
This applies also to named fields for structs, and arrays, too. In general, all "composite value types" cannot contain themselves directly or indirectly unless there's a reference type between. It's somewhat obvious but it probably should be spec'ed out explicitly, after all it's something that typecheckers go though some length to check.
Labels changed: added documentation.
Owner changed to @griesemer.
Status changed to Accepted.