From: Rob Pike Date: Fri, 22 Mar 2013 17:03:55 +0000 (-0700) Subject: spec: add example showing missing return statement X-Git-Tag: go1.1rc2~379 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d02089101c9d8375d991b679c9a1c8432e415cd8;p=gostls13.git spec: add example showing missing return statement Will help people find the rules by searching the spec by having a comment saying "missing return"; "terminating statement" does not evoke the rule to the uninitiated. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7838044 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index ebef65916e..2136d8bbe8 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -1964,6 +1964,17 @@ result parameters, the function body's statement list must end in a terminating statement.

+
+func findMarker(c <-chan int) int {
+	for i := range c {
+		if x := <-c; isMarker(x) {
+			return x
+		}
+	}
+	// invalid: missing return statement.
+}
+
+

A function declaration may omit the body. Such a declaration provides the signature for a function implemented outside Go, such as an assembly routine.