2020-09-23 16:14:34 +00:00
|
|
|
package testdata
|
|
|
|
|
|
|
|
func NoIndexProvided() {
|
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[:] // want "Expression is already a slice."
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func StartIndexProvided_NoDiagnostic() {
|
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[1:]
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func EndIndexProvided_NoDiagnostic() {
|
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[:2]
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BothIndicesProvided_NoDiagnostic() {
|
|
|
|
x := []byte{'f', 'o', 'o'}
|
|
|
|
y := x[1:2]
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func StringSlice() {
|
|
|
|
x := "foo"
|
|
|
|
y := x[:] // want "Expression is already a slice."
|
|
|
|
if len(y) == 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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"}
|
|
|
|
}
|