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
go/types/types2: generic functions must have a function body #47069
Comments
@ianlancetaylor Do you see any reason why we would want to allow leaving away the function body for a generic function? (I don't know how an external implementation would work.) |
I can't think of any way that it would make sense to omit the body of a generic function. A generic function can only be used if it is instantiated, and the compiler can't instantiate without a body. |
Change https://golang.org/cl/340911 mentions this issue: |
… must have a body Add the respective check and add missing bodies to tests. Use {} as body for functions that don't return a result. Use { panic(0) } as body for functions that return a result. For #47069. Change-Id: Ia5d7525c9c036baf8a955d13bff448401e08235e Reviewed-on: https://go-review.googlesource.com/c/go/+/340911 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This was fixed in |
Reminder issue: Currently, the type checkers permit generic functions without function body. We (probably) can't/won't permit external implementations of generic functions.
The linker will probably complain if a generic function body is missing, but we should report a nice error during type checking. The fix is trivial, but there are many generic function type checker tests that don't use function bodies.
cc: @findleyr, @mdempsky, @ianlancetaylor
The text was updated successfully, but these errors were encountered: