diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2022-03-07 05:43:40 -0800 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2022-03-07 14:07:18 +0000 |
| commit | d1820f748f8d63da8ef602e53d1db224f072be8f (patch) | |
| tree | a37739561200217422e765a36ae9455758a0d130 /test/typeparam | |
| parent | ac3ba9790762113bbc4ce1e8068654ce9579d3d6 (diff) | |
| download | go-d1820f748f8d63da8ef602e53d1db224f072be8f.tar.xz | |
test: add test case for #51521
The test case is already working with unified IR, so add it to make
sure we don't regress while finishing unified IR's support for
dictionaries.
Updates #51521.
Change-Id: Ib7c8bf9612d30cd552e8e631fd0d487dcb177f14
Reviewed-on: https://go-review.googlesource.com/c/go/+/390356
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test/typeparam')
| -rw-r--r-- | test/typeparam/issue51521.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/typeparam/issue51521.go b/test/typeparam/issue51521.go new file mode 100644 index 0000000000..5eb4e35c18 --- /dev/null +++ b/test/typeparam/issue51521.go @@ -0,0 +1,30 @@ +// run + +// Copyright 2022 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 main + +import ( + "fmt" + "strings" +) + +type I interface{ M() } + +func F[P I](p P) { defer catch(); p.M() } +func G[T any]() { defer catch(); interface{ M() T }.M(nil) } + +func main() { + F[I](nil) + G[int]() +} + +func catch() { + err := recover() + if err, ok := err.(error); ok && strings.Contains(err.Error(), "nil pointer dereference") { + return + } + fmt.Println("FAIL", err) +} |
