VB Code Unavailability Error / Warning

I have been working with VB.Net most of all for more than a year and just noticed it.

Am I losing my mind, or does VB.Net NOT have an "Unreachable code" warning?

The following compilations are pretty happy with the first warning or error, even though there is an answer between the two calls from the letter.

Sub Main()
    Console.WriteLine("Hello World")
    Return
    Console.WriteLine("Unreachable code, will never run")
End Sub

Am I missing something? Is there any way to switch this to something that I cannot find.

If not, is there a good reason to miss it? (that is, or I'm right in thinking that this is a sad state of things)

I apologize for this question, this is not an insult, I would like to answer.

thanks


I raised this on MS Connect since error # 428529

Update

I received the following from the VB team program manager:

, . , . , , , :

Sub Main()
    Dim x As Integer
    Return
    x = 4
End Sub

, x . , .

+5
4

, . - , , , VB, . ,

  • Goto
  • . (Resume, Goto ..)

, Connect. , Connect, , .

+4

.

, , .

- "On Error/Resume". .

:

"On Error" " ", . - "On Error/Resume , ".:)

"On Error" "" .

The big problem is how the existing DFA code is implemented. It does not use a control flow chart, and therefore changing it becomes very costly. I think that if you want to solve these problems, you really need to rip out the existing DFA code and replace it with something that uses the control flow graph.

+1
source

AFAIK, you are correct that VB.NET does not give you a warning. However, C #.

0
source

All Articles