]> Cypherpunks.ru repositories - gostls13.git/commitdiff
test: add test case for #51521
authorMatthew Dempsky <mdempsky@google.com>
Mon, 7 Mar 2022 13:43:40 +0000 (05:43 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 7 Mar 2022 14:07:18 +0000 (14:07 +0000)
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>
test/run.go
test/typeparam/issue51521.go [new file with mode: 0644]

index 6339095d954d0100618b0feffeeb37974c7a91f4..869911a4265f5c898c82004ceeb337fa52f069b0 100644 (file)
@@ -1999,7 +1999,8 @@ var types2Failures32Bit = setOf(
 )
 
 var g3Failures = setOf(
-       "typeparam/nested.go", // -G=3 doesn't support function-local types with generics
+       "typeparam/nested.go",     // -G=3 doesn't support function-local types with generics
+       "typeparam/issue51521.go", // -G=3 produces bad panic message and link error
 )
 
 // In all of these cases, -G=0 reports reasonable errors, but either -G=0 or types2
diff --git a/test/typeparam/issue51521.go b/test/typeparam/issue51521.go
new file mode 100644 (file)
index 0000000..5eb4e35
--- /dev/null
@@ -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)
+}