-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
package main
import (
"fmt"
"reflect"
)
var x = struct{ a, _, c int }{1, 2, 3}
func main() {
var y = struct{ a, _, c int }{1, 2, 3}
fmt.Println(x)
fmt.Println(y)
fmt.Println(reflect.ValueOf(x).Field(1).Int())
fmt.Println(reflect.ValueOf(y).Field(1).Int())
fmt.Println(x == y)
}Currently (Go 1.12, master) says:
{1 2 3}
{1 0 3}
2
0
true
The x == y part returning true is defined by the spec, but x and y getting a different value for the blank identifier is... weird. I see nothing in the spec that addresses this directly but if squint I might be able to connect some different parts and make guesses as to intent.
But Go 1.4 - Go 1.8 fail to compile with:
./x.go:11: cannot refer to blank field or method
Go 1.9 is the first version where the program above compiles and returns that result.
/cc @ianlancetaylor @griesemer @josharian @cherrymui @randall77 @davecheney
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.