You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: standard/variables.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -333,17 +333,7 @@ The definite-assignment state of *v* at the beginning of a case’s guard clause
333
333
-Iftheswitch label containing that guard clause ([§13.8.3](statements.md#1383-the-switch-statement)) is not reachable: “definitely assigned”.
334
334
- Otherwise, the state of *v* is the same as the state of *v* after *expr*.
335
335
336
-
The definite-assignment state of *v* on the control flow transfer to a reachable switch block statement list is
337
-
338
-
- If the control transfer was due to a ‘goto case’ or ‘goto default’ statement, then the state of *v* is the same as the state at the beginning of that ‘goto’ statement.
339
-
- If the control transfer was due to the `default` label of the switch, then the state of *v* is the same as the state of *v* after *expr*.
340
-
- If the control transfer was due to an unreachable switch label, then the state of *v* is “definitely assigned”.
341
-
- If the control transfer was due to a reachable switch label with a guard clause, then the state of *v* is the same as the state of *v* after the guard clause.
342
-
- If the control transfer was due to a reachable switch label without a guard clause, then the state of *v* is
343
-
- If *v* is a pattern variable declared in the *switch_label*: “definitely assigned”.
344
-
- Otherwise, the state of *v* is the same as the stat of *v* after *expr*.
345
-
346
-
> *Example*: The third rule eliminates the need for the compiler to issue an error if an unassigned variable is accessed in unreachable code. The state of *b* is "definitely assigned" in the unreachable switch label `case 2 when b`.
336
+
> *Example*: The second rule eliminates the need for the compiler to issue an error if an unassigned variable is accessed in unreachable code. The state of *b* is "definitely assigned" in the unreachable switch label `case 2 when b`.
347
337
>
348
338
> ```csharp
349
339
> bool b;
@@ -356,6 +346,16 @@ The definite-assignment state of *v* on the control flow transfer to a reachable
356
346
>
357
347
>*endexample*
358
348
349
+
Thedefinite-assignmentstateof*v*onthecontrolflowtransfertoareachableswitch block statement list is
350
+
351
+
- If the control transfer was due to a ‘goto case’ or ‘goto default’ statement, then the state of *v* is the same as the state at the beginning of that ‘goto’ statement.
352
+
- If the control transfer was due to the `default` label of the switch, then the state of *v* is the same as the state of *v* after *expr*.
353
+
- If the control transfer was due to an unreachable switch label, then the state of *v* is “definitely assigned”.
354
+
- If the control transfer was due to a reachable switch label with a guard clause, then the state of *v* is the same as the state of *v* after the guard clause.
355
+
- If the control transfer was due to a reachable switch label without a guard clause, then the state of *v* is
356
+
- If *v* is a pattern variable declared in the *switch_label*: “definitely assigned”.
357
+
- Otherwise, the state of *v* is the same as the stat of *v* after *expr*.
358
+
359
359
A consequence of these rules is that a pattern variable declared in a *switch_label* will be “not definitely assigned” in the statements of its switch section if it is not the only reachable switch label in its section.
0 commit comments