-
Notifications
You must be signed in to change notification settings - Fork 18k
spec: disallow recursive embedded interfaces #1814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
On a related subject, the spec does not say anything about struct types referring to themselves directly or indirectly via field types (of named or anonymus fields). With respect to the above example: While this special case may be easy to detect, more complicated indirect scenarios are possible: type E1 interface { E2 } type E2 interface { E3 } ... type En interface { E1 } all of which are empty and thus theoretically legal. This will be harder to detect and has no practical value. Such self-recursive interface types should not be allowed as per current compiler implementation. Changing this to a documentation issue: The spec should probably clarify what forms of direct and indirect recursions are legal in type declarations. Labels changed: added documentation, removed compilerbug, languagechange. |
Issue #1815 has been merged into this issue. |
I don't believe that type E interface { E } is any more legal than type T struct { T } In both cases there exists a minimal fixed point that could in theory be arrived upon, but nothing else in the language requires such analysis. It's not just this specific case either. I think the interface embedding graph needs to be cycle free. Russ |
Owner changed to builder@golang.org. |
This issue was closed by revision 388816a. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: