dotnet / dotnet/csharpstandard

13.2 End points and reachability: variable declaration reachability

Open
#141 7 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

It looks like we are missing _variable declaration_ exception from a list of specially handled statements in 14.2.

Consider

``` csharp
static class Program
{
static void Main(string[] args)
{
goto L;
int v; // CSC reports a warning Unreachable code detected here
L:
v = 1;
}
}
```

Proposal:

Add a new text block to section 14.2, possibly before "The block of a function member is always considered reachable"

> The local variable declaration and local constant declaration are always considered reachable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.