| 1 |
package pkg |
| 2 |
|
| 3 |
func fn1(x int) bool { |
| 4 |
println(x) |
| 5 |
return fn1(x + 1) //@ diag(`infinite recursive call`) |
| 6 |
return true |
| 7 |
} |
| 8 |
|
| 9 |
func fn2(x int) bool { |
| 10 |
println(x) |
| 11 |
if x > 10 { |
| 12 |
return true |
| 13 |
} |
| 14 |
return fn2(x + 1) |
| 15 |
} |
| 16 |
|
| 17 |
func fn3(x int) bool { |
| 18 |
println(x) |
| 19 |
if x > 10 { |
| 20 |
goto l1 |
| 21 |
} |
| 22 |
return fn3(x + 1) |
| 23 |
l1: |
| 24 |
println(x) |
| 25 |
return true |
| 26 |
} |
| 27 |
|
| 28 |
func fn4(p *int, n int) { |
| 29 |
if n == 0 { |
| 30 |
return |
| 31 |
} |
| 32 |
x := 0 |
| 33 |
fn4(&x, n-1) |
| 34 |
if x != n { |
| 35 |
panic("stack is corrupted") |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
func fn5(p *int, n int) { |
| 40 |
x := 0 |
| 41 |
fn5(&x, n-1) //@ diag(`infinite recursive call`) |
| 42 |
if x != n { |
| 43 |
panic("stack is corrupted") |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
func fn6() { |
| 48 |
go fn6() |
| 49 |
} |
| 50 |
|
| 51 |
type T struct { |
| 52 |
n int |
| 53 |
} |
| 54 |
|
| 55 |
func (t T) Fn1() { |
| 56 |
t.Fn1() //@ diag(`infinite recursive call`) |
| 57 |
} |
| 58 |
|
| 59 |
func (t T) Fn2() { |
| 60 |
x := T{} |
| 61 |
x.Fn2() //@ diag(`infinite recursive call`) |
| 62 |
} |
| 63 |
|
| 64 |
func (t T) Fn3() { |
| 65 |
if t.n == 0 { |
| 66 |
return |
| 67 |
} |
| 68 |
t.Fn1() |
| 69 |
} |