Skip to content

Single-line vb if statement generates unreasonable compile error #45158

@Youssef1313

Description

@Youssef1313

Version Used:

Visual Studio 2019

Steps to Reproduce:

I had a VB.NET project that was compiling without problem in VS 2015.
Now, when I opened it using VS 2019 it doesn't.

Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
    If MessageBox.Show(EXIT_MESSAGE, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then End Else e.Cancel = True
End Sub

However, the following code compiles without problems:

Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
    If MessageBox.Show(EXIT_MESSAGE, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
        End
    Else
        e.Cancel = True
    End If
End Sub

Expected Behavior:

Both codes should compile in VS 2019

Actual Behavior:

The first doesn't compile, while the second does.

Was that an announced breaking-change? or it's a regression bug?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions