Closed
Description
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.