Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / staticcheck / testdata / src / _CheckSliceOutOfBounds.go.disabled
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/_CheckSliceOutOfBounds.go.disabled b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/_CheckSliceOutOfBounds.go.disabled
new file mode 100644 (file)
index 0000000..c98650c
--- /dev/null
@@ -0,0 +1,65 @@
+package pkg
+
+func fn1() {
+       var s []int
+       s[0] = 0 // MATCH /index out of bounds/
+}
+
+func fn2() {
+       s := make([]int, 2)
+       s[2] = 0 // MATCH /index out of bounds/
+}
+
+func fn3() {
+       var s []int
+       s[0] = 0 // MATCH /index out of bounds/
+
+       s = make([]int, 2)
+       s[2] = 0 // MATCH /index out of bounds/
+}
+
+func fn4() {
+       s := make([]int, 2)
+       s = append(s, 1)
+       s[0] = 0
+       s[1] = 0
+       s[2] = 0
+       s[3] = 0 // MATCH /index out of bounds/
+}
+
+func fn5(s []int) {
+       s[2] = 0
+}
+
+func fn6(s []int) {
+       s = s[:2]
+       s[2] = 0 // MATCH /index out of bounds/
+}
+
+func fn7() {
+       s := make([]int, 2)
+       fn(s[2]) // MATCH /index out of bounds/
+}
+
+func fn8() {
+       s := []int{}
+       s[0] = 1 // MATCH /index out of bounds/
+}
+
+func fn9() {
+       s := []int{}
+       ptr(&s)
+       s[0] = 1
+}
+
+func fn10() {
+       var x []byte
+       for _, y := range x {
+               println(y)
+       }
+}
+
+func fn(int) {
+       println() // make it unpure
+}
+func ptr(*[]int) {}