-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/compile: apparent infinite expansion of recursive function #48711
Comments
This is pretty similar to #48018 , which I am planning to fix by having a limit on the depth or number of instantiations for the same function/method. This case should be handled by the same fix that I add for #48018. (Both this case and #48018 could possibly be handled if we computed some/all dictionaries and type descriptors at run time, but we compute all dictionaries at compile time and don't want to change that.) |
Thanks, please feel free to close this as a dupe of #48018 if that would be helpful, I missed that in my search for dupes. They might be slightly different but I agree that the fix should probably be the same. Interestingly I see that @griesemer and I both suggested that the type checker could/should detect this, but I think that might be overly optimistic. Detecting this would require a lot more machinery than we currently have. This came up because @timothy-king and I were talking about recursive instantiation. go/ssa will need a similar limit. |
Friendly ping that this is a release-blocking issue for Go 1.18. |
CL addressing this is in progress. |
Change https://golang.org/cl/362394 mentions this issue: |
The following program type-checks, but appears to grow unbounded during compilation:
This is not surprising: the program was constructed to require an infinitely growing number of function instances. See also #48098 and #48703: infinitely expanding instances are generally problematic.
Not sure where it is best to handle this. It seems like something that could be detected by the type-checker, but there can be an arbitrary number of functions involved in this infinite expansion. Maybe it would be easier for the compiler to enforce a limit on recursive instantiation.
CC @griesemer @danscales @randall77 @timothy-king
The text was updated successfully, but these errors were encountered: