Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB -> C#: Switch statement generates unreachable code #432

Closed
mrmonday opened this issue Nov 19, 2019 · 1 comment · Fixed by #829
Closed

VB -> C#: Switch statement generates unreachable code #432

mrmonday opened this issue Nov 19, 2019 · 1 comment · Fixed by #829
Labels
enhancement VB -> C# Specific to VB -> C# conversion

Comments

@mrmonday
Copy link
Contributor

Input code

Class A
    Function Add(ByVal x As Integer, ByVal b As Boolean) As Integer
        Select Case x
            Case 2
                If b Then
                    Return 4
                Else
                    Return 6
                End If
        End Select
        Return 3
    End Function
End Class

Erroneous output

class A
{
    public int Add(int x, bool b)
    {
        switch (x)
        {
            case 2:
                {
                    if (b)
                        return 4;
                    else
                        return 6;
                    break;
                }
        }
        return 3;
    }
}

Expected output

class A
{
    public int Add(int x, bool b)
    {
        switch (x)
        {
            case 2:
                {
                    if (b)
                        return 4;
                    else
                        return 6;
                }
        }
        return 3;
    }
}

Details

  • Version in use: 7.2.0

Produces:

warning CS0162: Unreachable code detected
@mrmonday
Copy link
Contributor Author

Similar issue with Throw New Exception() too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants