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: generic function type assignment fails to type check correctly #40060

Closed
rogpeppe opened this issue Jul 5, 2020 · 4 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rogpeppe
Copy link
Contributor

rogpeppe commented Jul 5, 2020

commit 34f7622

The following program seems like it should compile OK, but it does not:

package main

func main() {
}

type S1(type T) struct {
	x S2(T)
}

type S2(type T) struct {
	y sfunc(T)
}

type sfunc(type T) func(*S1(T))

func (*S1(T)) a() {}

func (i *S1(T)) b(f sfunc(T)) {
	i.x.y = f
}

It produces the error:

prog.go2:19:10: cannot use f (variable of type sfunc(T)) as sfunc(T) value in assignment
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 6, 2020
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jul 6, 2020
@ianlancetaylor
Copy link
Contributor

This looks like a bug in the type checker.

@griesemer
Copy link
Contributor

griesemer commented Jul 7, 2020

One of the functions is not properly instantiated; definitively a type-checker issue.

@rogpeppe
Copy link
Contributor Author

rogpeppe commented Jul 7, 2020

Note that it works OK if the apparently unrelated method a is removed, which is odd.

@rogpeppe
Copy link
Contributor Author

This now works correctly on tip.

@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 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants