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

cmd/go2go: recursive type constraint fails with confusing error #40882

Open
benjaminjkraft opened this issue Aug 19, 2020 · 1 comment
Open

cmd/go2go: recursive type constraint fails with confusing error #40882

benjaminjkraft opened this issue Aug 19, 2020 · 1 comment
Assignees
Milestone

Comments

@benjaminjkraft
Copy link

@benjaminjkraft benjaminjkraft commented Aug 19, 2020

Here's a type:

type Rec[type T Rec[T]] interface{ r(T) }

Currently go2go complains with confusing errors; the first declaration fails with Rec is not a generic type (it obviously is) and the equivalent type Rec[type T Rec] interface{ r(T) } fails with Rec is not an interface (it also obviously is).

I assume this shouldn't be allowed: to know if Rec[T] is a valid type for T to implement, we need to know if T implements Rec[T], which is circular. But I can't find anything in the draft design that would prohibit it.

(playground for convenience)

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 19, 2020

I don't think these cases should be permitted but it does seem that the errors generated by the type checker are not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.