Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
issue51521.go31 linesDownload Raw Back to typeparam
1// run2 3// Copyright 2022 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7package main8 9import (10	"fmt"11	"strings"12)13 14type I interface{ M() }15 16func F[P I](p P) { defer catch(); p.M() }17func G[T any]()  { defer catch(); interface{ M() T }.M(nil) }18 19func main() {20	F[I](nil)21	G[int]()22}23 24func catch() {25	err := recover()26	if err, ok := err.(error); ok && strings.Contains(err.Error(), "nil pointer dereference") {27		return28	}29	fmt.Println("FAIL", err)30}31 
codekingpro/portable-devtools · Team Ai