I've been mostly working with VB.Net for over a year and just noticed this
Am I going insane, or does VB.Net NOT have an "Unreachable code" warning?
The following compiles quite happily with nary a warning or error, even though there is a return between the two writeline calls.
Sub Main()
Console.WriteLine("Hello World")
Return
Console.WriteLine("Unreachable code, will never run")
End Sub
Am I missing something? Is there some way to switch this on that I can't find.
If not, is there a good reason for it's omission? (i.e. or am I right in thinking this is a woeful state of affairs)
Forgive the air of rant about this question, it's not a rant, I would like an answer.
Thanks
I've raised this on MS Connect, as bug# 428529
Update
I received the following from the VB Teams program manager
Thanks for taking the time to report this issue. The compiler has limited support for this scenario, and as you point out we don't have warnings for unreachable code. There are some scenarios that our flow analysis algorithm does handle, such as the following:
Sub Main()
Dim x As Integer
Return
x = 4
End Sub
In this case you'll get a warning that x has never been assigned. For the case you mentioned however we'll have to look at implementing that for a future release.