From 9905cec0dc04fd7cddb7c7504006b7aa618abd94 Mon Sep 17 00:00:00 2001
From: Robert Griesemer
-A block is a sequence of declarations and statements within matching
-brace brackets.
+A block is a possibly empty sequence of declarations and statements
+within matching brace brackets.
@@ -1490,10 +1491,13 @@ In addition to explicit blocks in the source code, there are implicit blocks:
-Block = "{" { Statement ";" } "}" .
+Block = "{" StatementList "}" .
+StatementList = { Statement ";" } .
if
, for
, and switch
+ switch
or select
statement
+
-FunctionDecl = "func" FunctionName Signature [ Body ] . +FunctionDecl = "func" FunctionName ( Function | Signature ) . FunctionName = identifier . -Body = Block . +Function = Signature FunctionBody . +FunctionBody = Block .+
+If the function's signature declares +result parameters, the function body's statement list must end in +a terminating 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. @@ -1972,13 +1983,13 @@ func flushICache(begin, end uintptr) // implemented externally
-A method is a function with a receiver. -A method declaration binds an identifier, the method name, to a method. -It also associates the method with the receiver's base type. +A method is a function with a receiver. +A method declaration binds an identifier, the method name, to a method, +and associates the method with the receiver's base type.
-MethodDecl = "func" Receiver MethodName Signature [ Body ] . +MethodDecl = "func" Receiver MethodName ( Function | Signature ) . Receiver = "(" [ identifier ] [ "*" ] BaseTypeName ")" . BaseTypeName = identifier .@@ -2284,12 +2295,11 @@ noteFrequency := map[string]float32{
-A function literal represents an anonymous function. -It consists of a specification of the function type and a function body. +A function literal represents an anonymous function.
-FunctionLit = FunctionType Body . +FunctionLit = "func" Function .
@@ -3843,6 +3853,84 @@ Statement = SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl .+
+A terminating statement is one of the following: +
+ +panic
.
+
+ +All other statements are not terminating. +
+ ++A statement list ends in a terminating statement if the list +is not empty and its final statement is terminating. +
+true
.
ExprSwitchStmt = "switch" [ SimpleStmt ";" ] [ Expression ] "{" { ExprCaseClause } "}" . -ExprCaseClause = ExprSwitchCase ":" { Statement ";" } . +ExprCaseClause = ExprSwitchCase ":" StatementList . ExprSwitchCase = "case" ExpressionList | "default" .@@ -4213,7 +4301,7 @@ expression
x
. As with type assertions, x
must be of
TypeSwitchStmt = "switch" [ SimpleStmt ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" . TypeSwitchGuard = [ identifier ":=" ] PrimaryExpr "." "(" "type" ")" . -TypeCaseClause = TypeSwitchCase ":" { Statement ";" } . +TypeCaseClause = TypeSwitchCase ":" StatementList . TypeSwitchCase = "case" TypeList | "default" . TypeList = Type { "," Type } .@@ -4536,7 +4624,7 @@ cases all referring to communication operations.
SelectStmt = "select" "{" { CommClause } "}" . -CommClause = CommCase ":" { Statement ";" } . +CommClause = CommCase ":" StatementList . CommCase = "case" ( SendStmt | RecvStmt ) | "default" . RecvStmt = [ ExpressionList "=" | IdentifierList ":=" ] RecvExpr . RecvExpr = Expression . -- 2.48.1