Source file
test/fixedbugs/issue22083.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 import (
13 "runtime/debug"
14 "strings"
15 )
16
17 type Wrapper struct {
18 a []int
19 }
20
21 func (w Wrapper) Get(i int) int {
22 return w.a[i]
23 }
24
25 func main() {
26 defer func() {
27 e := recover()
28 if e == nil {
29 panic("bounds check didn't fail")
30 }
31 stk := string(debug.Stack())
32 if !strings.Contains(stk, "issue22083.go:40") {
33 panic("wrong stack trace: " + stk)
34 }
35 }()
36 foo := Wrapper{a: []int{0, 1, 2}}
37 _ = foo.Get(0)
38 _ = foo.Get(1)
39 _ = foo.Get(2)
40 _ = foo.Get(3)
41 }
42
View as plain text