Source file
test/fixedbugs/issue28797.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "fmt"
11 )
12
13
14
15
16 func test(f func()) {
17 defer func() {
18 r := recover()
19 if r == nil {
20 panic("panic wasn't recoverable")
21 }
22 }()
23 f()
24 }
25
26
27 func id(x int) int {
28 return x
29 }
30
31 func main() {
32 test(foo)
33 test(bar)
34 }
35
36 func foo() {
37 b := make([]byte, 0)
38 b = append(b, 1)
39 id(len(b))
40 id(len(b) - 2)
41 s := string(b[1 : len(b)-2])
42 fmt.Println(s)
43 }
44
45 func bar() {
46 b := make([]byte, 1)
47 b = append(b, 1)
48 i := id(-1)
49 if i < len(b) {
50 s := string(b[1:i])
51 fmt.Println(s)
52 }
53 }
54
View as plain text