2020-09-23 16:14:34 +00:00
|
|
|
package testdata
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// NoIndexProvided --
|
2020-09-23 16:14:34 +00:00
|
|
|
func NoIndexProvided() {
|
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[:] // want "Expression is already a slice."
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// StartindexprovidedNodiagnostic --
|
2021-02-03 16:59:17 +00:00
|
|
|
func StartindexprovidedNodiagnostic() {
|
2020-09-23 16:14:34 +00:00
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[1:]
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// EndindexprovidedNodiagnostic --
|
2021-02-03 16:59:17 +00:00
|
|
|
func EndindexprovidedNodiagnostic() {
|
2020-09-23 16:14:34 +00:00
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[:2]
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// BothindicesprovidedNodiagnostic --
|
2021-02-03 16:59:17 +00:00
|
|
|
func BothindicesprovidedNodiagnostic() {
|
2020-09-23 16:14:34 +00:00
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[1:2]
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// StringSlice --
|
2020-09-23 16:14:34 +00:00
|
|
|
func StringSlice() {
|
|
|
|
x := "foo"
|
|
|
|
y := x[:] // want "Expression is already a slice."
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// SliceFromFunction --
|
2020-09-23 16:14:34 +00:00
|
|
|
func SliceFromFunction() {
|
2021-01-25 21:27:30 +00:00
|
|
|
x := slice()[:] // want "Expression is already a slice."
|
2020-09-23 16:14:34 +00:00
|
|
|
if len(x) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-25 21:27:30 +00:00
|
|
|
func slice() []string {
|
2020-09-23 16:14:34 +00:00
|
|
|
return []string{"bar"}
|
|
|
|
}
|