diff options
author | Robert Griesemer <gri@golang.org> | 2014-03-05 11:59:53 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2014-03-05 11:59:53 -0800 |
commit | 0cedf35920e70f659d9e7ef91c14afdf07a6cd34 (patch) | |
tree | 372c945d09ee96f2761fb339cc6ae1c663c4c936 /doc | |
parent | 9cf93b26131d50294f68dbd02731b84c1c52d957 (diff) | |
download | go-0cedf35920e70f659d9e7ef91c14afdf07a6cd34.tar.gz |
spec: shadowed return parameters may be disallowed
This documents the implemented behavior of both
gc and gccgo as an implementation restriction.
NOT A LANGUAGE CHANGE.
Fixes issue 5425.
LGTM=rsc, r, iant
R=r, iant, rsc, ken
CC=golang-codereviews
https://codereview.appspot.com/71430043
Diffstat (limited to 'doc')
-rw-r--r-- | doc/go_spec.html | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html index 9043431c4..dada50357 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ <!--{ "Title": "The Go Programming Language Specification", - "Subtitle": "Version of March 4, 2014", + "Subtitle": "Version of March 5, 2014", "Path": "/ref/spec" }--> @@ -5002,6 +5002,21 @@ function. A "return" statement that specifies results sets the result parameters any deferred functions are executed. </p> +<p> +Implementation restriction: A compiler may disallow an empty expression list +in a "return" statement if a different entity (constant, type, or variable) +with the same name as a result parameter is in +<a href="#Declarations_and_scope">scope</a> at the place of the return. +</p> + +<pre> +func f(n int) (res int, err error) { + if _, err := f(n-1); err != nil { + return // invalid return statement: err is shadowed + } + return +} +</pre> <h3 id="Break_statements">Break statements</h3> |