go/src/weak
Michael Anthony Knyszek d62154db83 weak: don't panic when calling Value on a zero Pointer
Currently weak.Pointer.Value will panic if the weak.Pointer is
uninitialized (zero value) which goes against it's documentation. Fix
this and add a test. While we're here, also add a test to ensure
weak.Make[T](nil) is equivalent to the zero value of weak.Pointer[T].

Fixes #71153.

Change-Id: I4d9196026360bc42a5bfcb33ce449131ec251dba
Reviewed-on: https://go-review.googlesource.com/c/go/+/641095
Reviewed-by: David Finkel <david.finkel@gmail.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-01-07 10:08:42 -08:00
..
doc.go weak: align weak.Pointer documentation with runtime.AddCleanup 2024-12-09 18:29:19 +00:00
pointer.go weak: don't panic when calling Value on a zero Pointer 2025-01-07 10:08:42 -08:00
pointer_test.go weak: don't panic when calling Value on a zero Pointer 2025-01-07 10:08:42 -08:00