Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version devel +08a3a7c Thu Feb 2 02:14:50 2017 +0000 linux/amd64
What operating system and processor architecture are you using (go env)?
linux/amd64
What did you do?
package main
import (
"fmt"
"q"
)
func main() {
var a q.A
var b q.B // i'm a named unnamed type !!!
fmt.Printf("%T\t%T\n", a, b)
}
What did you expect to see?
deadwood(~/src) % go run main.go
q.A q.B
What did you see instead?
deadwood(~/src) % go run main.go
q.A []int
Discussion
Aliases shouldn't not apply to unnamed type. Their is no "code repair" story in moving from one unnamed type to another. Allowing aliases on unnamed types means I can no longer teach Go as simply named and unnamed types. Instead I have to say
oh, unless it's an alias, in which case you have to remember that it could be an unnamed type, even when you import to from another package.
And worse, it will enable people to promulgate readability anti patterns like
Please do not allow unnamed types to be aliased.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version)?go version devel +08a3a7c Thu Feb 2 02:14:50 2017 +0000 linux/amd64
What operating system and processor architecture are you using (
go env)?linux/amd64
What did you do?
What did you expect to see?
What did you see instead?
Discussion
Aliases shouldn't not apply to unnamed type. Their is no "code repair" story in moving from one unnamed type to another. Allowing aliases on unnamed types means I can no longer teach Go as simply named and unnamed types. Instead I have to say
And worse, it will enable people to promulgate readability anti patterns like
Please do not allow unnamed types to be aliased.