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

Open
mrmonday opened this issue Nov 19, 2019 · 1 comment
Open

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

mrmonday opened this issue Nov 19, 2019 · 1 comment
Labels

Comments

@mrmonday
Copy link
Contributor

@mrmonday mrmonday commented Nov 19, 2019

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

This comment has been minimized.

Copy link
Contributor Author

@mrmonday mrmonday commented Nov 19, 2019

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
Projects
None yet
2 participants
You can’t perform that action at this time.