roslyn: No warning for unreachable code after throw expression
Version Used: 2.3.0.61719 (5fbdd5c5)
Steps to Reproduce:
using System;
class X
{
public static void Main ()
{
var x = true ? throw new NullReferenceException () : 1;
x = 2; // This code is unreachable but no info about it
return;
}
}
Expected Behavior:
Proper warning about unreachable code
Actual Behavior:
No warning.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (19 by maintainers)
@CyrusNajmabadi consider following sample (it’s just same code shaped differently)
Now if C# compiler would really follow your statement of
then this code should fail to compile because
z
is not always assigned to before control leaves the current method but it compiles fine.