From 1d44af8dbaf3e7a231b0276b4fe12bc699a3ab39 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 13 Sep 2023 12:19:36 +0100 Subject: [PATCH] Add rule for goto --- standard/statements.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/standard/statements.md b/standard/statements.md index 08fe82238..6a0c07a97 100644 --- a/standard/statements.md +++ b/standard/statements.md @@ -519,7 +519,9 @@ A local function is declared at block scope, and that function may capture varia When the type of `this` is a struct type, it is a compile-time error for the body of a local function to access `this`. This is true whether the access is explicit (as in `this.x`) or implicit (as in `x` where `x` is an instance member of the struct). This rule only prohibits such access and does not affect whether member lookup results in a member of the struct. -> *Note*: this rule mirrors the rule for anonymous functions in [§12.19.3](expressions.md#12193-anonymous-function-bodies). *end note* +It is a compile-time error for the body of the local function to contain a `goto` statement, a `break` statement, or a `continue` statement whose target is outside the body of the local function. + +> *Note*: the above rules for `this` and `goto` mirror the rules for anonymous functions in [§12.19.3](expressions.md#12193-anonymous-function-bodies). *end note* A local function may be called from a lexical point prior to its declaration. However, it is a compile-time error for the function to be declared lexically prior to the declaration of a variable used in the local function ([§7.7](basic-concepts.md#77-scopes)).