From 08bec0db3970319ef868b3c11d6cc077cab408b1 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 18 Dec 2023 08:53:03 +0000 Subject: [PATCH] builtin: mention PanicNilError in comments of recover As of CL 461956 `recover` will not return `nil` if `panic` is called with `nil`. I have updated comments of `recover` to account for this change. Change-Id: Ibd0b27fe9b89fb29349b62ad34e762239a1d165b GitHub-Last-Rev: c773abb75c8cd8e08c3470f064a3205573156fea GitHub-Pull-Request: golang/go#64393 Reviewed-on: https://go-review.googlesource.com/c/go/+/544975 Reviewed-by: Mauri de Souza Meneguzzo Reviewed-by: Than McIntosh Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- src/builtin/builtin.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/builtin/builtin.go b/src/builtin/builtin.go index da0ace1498..668c799ca7 100644 --- a/src/builtin/builtin.go +++ b/src/builtin/builtin.go @@ -284,9 +284,10 @@ func panic(v any) // by restoring normal execution and retrieves the error value passed to the // call of panic. If recover is called outside the deferred function it will // not stop a panicking sequence. In this case, or when the goroutine is not -// panicking, or if the argument supplied to panic was nil, recover returns -// nil. Thus the return value from recover reports whether the goroutine is -// panicking. +// panicking, recover returns nil. +// +// Prior to Go 1.21, recover would also return nil if panic is called with +// a nil argument. See [panic] for details. func recover() any // The print built-in function formats its arguments in an -- 2.48.1