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

griesemer opened this issue Jun 7, 2018 · 1 comment


Copy link

@griesemer griesemer commented Jun 7, 2018


package p
func f(f)

cmd/compile reports "f is not a type", but go/types (after 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 this to the Go1.12 milestone Jun 7, 2018
@griesemer griesemer self-assigned this Jun 7, 2018
Copy link

@gopherbot gopherbot commented Sep 17, 2018

Change mentions this issue: go/types: don't report cycle error if clearer error follows


@gopherbot gopherbot closed this in d97b11f Sep 17, 2018
@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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants