]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify panic behavior when deferring nil functions
authorRobert Griesemer <gri@golang.org>
Fri, 19 Sep 2014 20:32:07 +0000 (13:32 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 19 Sep 2014 20:32:07 +0000 (13:32 -0700)
Fixes #8107.

LGTM=iant, rsc, r
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/145960043

doc/go_spec.html

index e8bb35f0b0d1beb53ba6107650ac008565241cfb..da1e2a5d24f322e89ba030dcbf37d98cf0f985e7 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of August 28, 2014",
+       "Subtitle": "Version of September 19, 2014",
        "Path": "/ref/spec"
 }-->
 
@@ -5243,13 +5243,16 @@ Calls of built-in functions are restricted as for
 </p>
 
 <p>
-Each time the "defer" statement
+Each time a "defer" statement
 executes, the function value and parameters to the call are
 <a href="#Calls">evaluated as usual</a>
-and saved anew but the actual function body is not executed.
-Instead, deferred functions are executed immediately before
+and saved anew but the actual function is not invoked.
+Instead, deferred functions are invoked immediately before
 the surrounding function returns, in the reverse order
 they were deferred.
+If a deferred function value evaluates
+to <code>nil</code>, execution <a href="#Handling_panics">panics</a>
+when the function is invoked not when the "defer" statement is executed.
 </p>
 
 <p>