"Invalid IL code ... method body is empty" when using fallthrough case in switch statement.
This is a sibling of the earlier bug 21805. I'm not sure if this situation is specifically mentioned in the C# specification, so the current behavior might not necessarily be "wrong."
## Steps to reproduce
1. Compile the following program using `mcs`:
using System;
public enum Foo { One, Two };
class MainClass
{
public static void Main(string[] args)
{
const Foo foo = Foo.Two;
object obj;
switch (foo)
{
case Foo.One:
case Foo.Two:
obj = new object();
break;
}
Console.WriteLine(obj.ToString());
}
}
2. Run the program with `mono`.
## Result when compiled with `mcs`
### Command-line output from step 2
> $ mono Program.exe
> Unhandled Exception:
> System.InvalidProgramException: Invalid IL code in MainClass:Main (string[]): method body is empty.
>
> [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in MainClass:Main (string[]): method body is empty.
## Result when compiled with `csc`
> $ mono Program.exe
> System.Object
## Additional result (same on both `mcs` and `csc`)
If you remove `const` from the `foo` local variable, both compilers reject the code due to "Use of unassigned local variable 'obj'". Since `csc` has the same behavior as `mcs` in this "additional" case, the only issue with `mcs` is when `foo` is *not* marked `const`.
## Version Information
Tested with Mono 3.10.0 (detached/ac51002) and 3.10.1 (master/4e3ca74).
Fixed in master