mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
695a59b513
Add a simple test with an exported generic function that does recover/defer, to test that recover/defer are exported/imported properly (and a generic function with recover/defer works fine). Change-Id: Idc3af101cbb78fc96bf945f1f5eab2740dd8994b Reviewed-on: https://go-review.googlesource.com/c/go/+/353883 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
17 lines
307 B
Go
17 lines
307 B
Go
// Copyright 2021 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package a
|
|
|
|
import "fmt"
|
|
|
|
func F[T any](a T) {
|
|
defer func() {
|
|
if x := recover(); x != nil {
|
|
fmt.Printf("panic: %v\n", x)
|
|
}
|
|
}()
|
|
panic(a)
|
|
}
|