From 6e58cc8db65a4b1f3d0502257e564d6b87bd7861 Mon Sep 17 00:00:00 2001 From: Andrew Athan <24279435+aathan@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:12:28 -0800 Subject: [PATCH] Clarify description of recover in go_spec.html The previous language ("the return value of D's call to recover will be the value passed to the call of panic") causes temporary confusion when readers parse "will be" as a future event wherein panic() is called. The proposed change uses grammar that more clearly states the temporal relationships. --- doc/go_spec.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 18f88d5ead..5319d1d92f 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -7641,10 +7641,13 @@ panic(Error("cannot parse")) The recover function allows a program to manage behavior of a panicking goroutine. Suppose a function G defers a function D that calls -recover and a panic occurs in a function on the same goroutine in which G +recover and a panic occurs (i.e., panic is called) +in a function on the same goroutine in which G is executing. -When the running of deferred functions reaches D, -the return value of D's call to recover will be the value passed to the call of panic. +Subsequently, when the running of deferred functions reaches D, +the return value of D's call to recover is the value +that was previously passed to panic (i.e., at the call to panic +that caused the deferred functions to run). If D returns normally, without starting a new panic, the panicking sequence stops. In that case, the state of functions called between G and the call to panic