github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/test/fixedbugs/bug442.go (about)

     1  // run
     2  
     3  // Copyright 2012 The Go Authors.  All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Used to crash generating hash and == functions for struct
     8  // with leading _ field.  Issue 3607.
     9  
    10  package main
    11  
    12  type T struct {
    13  	_ int
    14  	X interface{}
    15  	_ string
    16  	Y float64
    17  }
    18  
    19  func main() {
    20  	m := map[T]int{}
    21  	m[T{X: 1, Y: 2}] = 1
    22  	m[T{X: 2, Y: 3}] = 2
    23  	m[T{X: 1, Y: 2}] = 3  // overwrites first entry
    24  	if len(m) != 2 {
    25  		println("BUG")
    26  	}
    27  }