X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fcoc-go-data%2Ftools%2Fpkg%2Fmod%2Fhonnef.co%2Fgo%2Ftools%40v0.0.1-2020.1.5%2Fstaticcheck%2Ftestdata%2Fsrc%2FCheckInfiniteRecursion%2FCheckInfiniteRecursion.go;fp=.config%2Fcoc%2Fextensions%2Fcoc-go-data%2Ftools%2Fpkg%2Fmod%2Fhonnef.co%2Fgo%2Ftools%40v0.0.1-2020.1.5%2Fstaticcheck%2Ftestdata%2Fsrc%2FCheckInfiniteRecursion%2FCheckInfiniteRecursion.go;h=b38c59c8acdfaa72f5cf6ee0442c1f1fd3f29db4;hb=4d07c77cf4d78cab8639e13ddc3c22495e585b0b;hp=0000000000000000000000000000000000000000;hpb=b3950616b54221c40a7dab9099bda675007e5b6e;p=dotfiles%2F.git 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/CheckInfiniteRecursion/CheckInfiniteRecursion.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/CheckInfiniteRecursion/CheckInfiniteRecursion.go new file mode 100644 index 00000000..b38c59c8 --- /dev/null +++ b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/CheckInfiniteRecursion/CheckInfiniteRecursion.go @@ -0,0 +1,69 @@ +package pkg + +func fn1(x int) bool { + println(x) + return fn1(x + 1) // want `infinite recursive call` + return true +} + +func fn2(x int) bool { + println(x) + if x > 10 { + return true + } + return fn2(x + 1) +} + +func fn3(x int) bool { + println(x) + if x > 10 { + goto l1 + } + return fn3(x + 1) +l1: + println(x) + return true +} + +func fn4(p *int, n int) { + if n == 0 { + return + } + x := 0 + fn4(&x, n-1) + if x != n { + panic("stack is corrupted") + } +} + +func fn5(p *int, n int) { + x := 0 + fn5(&x, n-1) // want `infinite recursive call` + if x != n { + panic("stack is corrupted") + } +} + +func fn6() { + go fn6() +} + +type T struct { + n int +} + +func (t T) Fn1() { + t.Fn1() // want `infinite recursive call` +} + +func (t T) Fn2() { + x := T{} + x.Fn2() // want `infinite recursive call` +} + +func (t T) Fn3() { + if t.n == 0 { + return + } + t.Fn1() +}