Home | History | Annotate | Download | only in fixedbugs
      1 // run
      2 
      3 // Copyright 2013 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 // issue 6269: name collision on method names for function local types.
      8 
      9 package main
     10 
     11 type foo struct{}
     12 
     13 func (foo) Error() string {
     14 	return "ok"
     15 }
     16 
     17 type bar struct{}
     18 
     19 func (bar) Error() string {
     20 	return "fail"
     21 }
     22 
     23 func unused() {
     24 	type collision struct {
     25 		bar
     26 	}
     27 	_ = collision{}
     28 }
     29 
     30 func main() {
     31 	type collision struct {
     32 		foo
     33 	}
     34 	s := error(collision{})
     35 	if str := s.Error(); str != "ok" {
     36 		println("s.Error() ==", str)
     37 		panic(`s.Error() != "ok"`)
     38 	}
     39 }
     40