modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/method1.go (about) 1 // errorcheck 2 3 // Copyright 2009 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 // Verify that method redeclarations are caught by the compiler. 8 // Does not compile. 9 10 package main 11 12 type T struct{} 13 14 func (t *T) M(int, string) // GCCGO_ERROR "previous" 15 func (t *T) M(int, float64) {} // ERROR "redeclared|redefinition" 16 17 func (t T) H() // GCCGO_ERROR "previous" 18 func (t *T) H() {} // ERROR "redeclared|redefinition" 19 20 func f(int, string) // GCCGO_ERROR "previous" 21 func f(int, float64) {} // ERROR "redeclared|redefinition" 22 23 func g(a int, b string) // GCCGO_ERROR "previous" 24 func g(a int, c string) // ERROR "redeclared|redefinition"