2020-09-14 10:49:15 +00:00
package testdata
type len struct { // want "Type 'len' shadows a predeclared identifier with the same name. Choose another name."
}
type int interface { // want "Type 'int' shadows a predeclared identifier with the same name. Choose another name."
}
2021-04-23 12:06:05 +00:00
// Struct --
2020-09-14 10:49:15 +00:00
func Struct ( ) {
type error struct { // want "Type 'error' shadows a predeclared identifier with the same name. Choose another name."
int int // No diagnostic because the name is always referenced indirectly through a struct variable.
}
}
2021-04-23 12:06:05 +00:00
// TypeAlias --
2020-09-14 10:49:15 +00:00
func TypeAlias ( ) {
type error string // want "Type 'error' shadows a predeclared identifier with the same name. Choose another name."
}
2021-04-23 12:06:05 +00:00
// UninitializedVarAndAssignments --
2020-09-14 10:49:15 +00:00
func UninitializedVarAndAssignments ( ) {
var error int // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
error = 1 // No diagnostic because the original declaration already triggered one.
if error == 0 {
}
}
2021-04-23 12:06:05 +00:00
// InitializedVar --
2020-09-14 10:49:15 +00:00
func InitializedVar ( ) {
error := 0 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
if error == 0 {
}
}
2021-04-23 12:06:05 +00:00
// FirstInVarList --
2020-09-14 10:49:15 +00:00
func FirstInVarList ( ) {
error , x := 0 , 1 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
if error == x {
}
}
2021-04-23 12:06:05 +00:00
// SecondInVarList --
2020-09-14 10:49:15 +00:00
func SecondInVarList ( ) {
x , error := 0 , 1 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
if error == x {
}
}
2021-04-23 12:06:05 +00:00
// Const --
2020-09-14 10:49:15 +00:00
func Const ( ) {
const error = 0 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name."
}
// Test function and parameter names.
func error ( len int ) { // want "Function 'error' shadows a predeclared identifier with the same name. Choose another name." "Identifier 'len' shadows a predeclared identifier with the same name. Choose another name."
if len == 0 {
}
// Test parameter in a new line.
f := func (
int string ) { // want "Identifier 'int' shadows a predeclared identifier with the same name. Choose another name."
}
f ( "" )
}
type receiver struct {
}
2021-04-23 12:06:05 +00:00
// Receiver is a test receiver function.
2020-09-14 10:49:15 +00:00
func ( s * receiver ) Receiver ( len int ) {
}