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: instantiate generic redeclared in this block #39653

Closed
kylelemons opened this issue Jun 17, 2020 · 5 comments
Closed

cmd/go2go: instantiate generic redeclared in this block #39653

kylelemons opened this issue Jun 17, 2020 · 5 comments
Assignees
Milestone

Comments

@kylelemons
Copy link
Contributor

@kylelemons kylelemons commented Jun 17, 2020

What version of Go are you using (go version)?

go2goplay.golang.org

What did you do?

https://go2goplay.golang.org/p/s37l9l0m7Du

type End struct{}

type Dimension(type P) struct {
	Name   string
	Parent P
}

func Dim(type Parent)(name string, p Parent) Dimension(Parent) {
	return Dimension(Parent){
		Name:   name,
		Parent: p,
	}
}

func main() {
	d := Dim("a", Dim("b", Dim("c", End{})))
	fmt.Printf("%T", d)
}

What did you expect to see?

Something like Dim(Dim(Dim(End))) except mangled as successful output

What did you see instead?

The following error:

./prog.go2:23: instantiate୦୦Dimension୦main୮aEnd redeclared in this block
	previous declaration at ./prog.go2:28
./prog.go2:21: cannot use p (type instantiate୦୦Dimension୦main୮aEnd) as type instantiate୦୦Dimension୦main୮aEnd in field value

This is either an incorrect error (if the code should be fine) or an error message that I am unable to interpret to be able to figure out what I did wrong.

@kylelemons
Copy link
Contributor Author

@kylelemons kylelemons commented Jun 17, 2020

It seems to work fine with one and two levels of nesting, but not three.

@andybons
Copy link
Member

@andybons andybons commented Jun 17, 2020

@andybons andybons added this to the Unplanned milestone Jun 17, 2020
@griesemer
Copy link
Contributor

@griesemer griesemer commented Jun 17, 2020

This looks like a bug in the translator part (type checking is fine).

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 17, 2020

Change https://golang.org/cl/238618 mentions this issue: [dev.go2go] go/go2go: make uses of typeInstantiations consistent

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 17, 2020

Thanks, this should be fixed now.

gopherbot pushed a commit that referenced this issue Jun 17, 2020
Fixes #39653

Change-Id: I98fd1bd4f0deccb5b4c2ed0d67d508c7f0117839
Reviewed-on: https://go-review.googlesource.com/c/go/+/238618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
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
5 participants
You can’t perform that action at this time.