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: better error message for "func f(f)" and similar declarations #25790

Closed
griesemer opened this issue Jun 7, 2018 · 1 comment
Closed
Labels
early-in-cycle A change that should be done early in the 3 month dev cycle. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

For

package p
func f(f)

cmd/compile reports "f is not a type", but go/types (after https://go-review.googlesource.com/c/go/+/116815) reports: "illegal cycle in declaration of f", which is ok, but not as good.

The problem is that the new cycle detection code doesn't know that we're looking for a type. If it knew, it could avoid reporting the cycle in favor of the subsequent error. Fixing this will likely require that we pass around a "context" parameter during type-checking which states the expectation for the expression to be checked (similar to the "top" parameter in the compiler's type checker). Not hard to do but possibly pervasive.

@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. early-in-cycle A change that should be done early in the 3 month dev cycle. labels Jun 7, 2018
@griesemer griesemer added this to the Go1.12 milestone Jun 7, 2018
@griesemer griesemer self-assigned this Jun 7, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/135700 mentions this issue: go/types: don't report cycle error if clearer error follows

@golang golang locked and limited conversation to collaborators Sep 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
early-in-cycle A change that should be done early in the 3 month dev cycle. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants