Debian Codegraph @

test/fixedbugs/issue74379b.go

raw
1 // run
2
3 // Copyright 2025 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 import (
10 "errors"
11 "fmt"
12 "os"
13 )
14
15 func crashOnErr(err error) int {
16 if err != nil {
17 panic(err)
18 }
19 return 10
20 }
21
22 func main() {
23 defer func() {
24 if recover() == nil {
25 fmt.Println("failed to have expected panic")
26 os.Exit(1)
27 }
28 }()
29
30 s := make([]int, crashOnErr(errors.New("test error")))
31 println("unreachable: len(s) =", len(s))
32 }