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
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@kylelemons
Copy link
Contributor

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

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

@andybons
Copy link
Member

@griesemer @ianlancetaylor

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 17, 2020
@andybons andybons added this to the Unplanned milestone Jun 17, 2020
@griesemer
Copy link
Contributor

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

@gopherbot
Copy link

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

@ianlancetaylor
Copy link
Contributor

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>
@golang golang locked and limited conversation to collaborators Jun 17, 2021
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

5 participants