Skip to content
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

Closed
griesemer opened this issue Jul 6, 2021 · 4 comments
Closed

go/types/types2: generic functions must have a function body #47069

griesemer opened this issue Jul 6, 2021 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

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

@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Jul 6, 2021
@griesemer griesemer added this to the Go1.18 milestone Jul 6, 2021
@griesemer griesemer self-assigned this Jul 6, 2021
@gopherbot gopherbot removed the NeedsFix The path to resolution is known, but the work has not been done. label Jul 6, 2021
@griesemer
Copy link
Contributor Author

@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.)

@ianlancetaylor
Copy link
Contributor

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.

@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Aug 9, 2021
@gopherbot
Copy link

Change https://golang.org/cl/340911 mentions this issue: [dev.typeparams] cmd/compile/internal/types2: parameterized functions must have a body

gopherbot pushed a commit that referenced this issue Aug 10, 2021
… 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>
@griesemer
Copy link
Contributor Author

This was fixed in types2 with the above CL, and in go/types with CL 342475.

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants